标签:mysql
操作系统 | centos 6.4 x86_64 |
mysql版本 | 5.5.33 |
安装依赖软件
# yum -y install gcc gcc-c++ ncurses-devel bison-devel libaio-devel
2. 安装cmake
# yum -y install cmake28
3. 编译安装
# groupadd -r mysql
# useradd -g mysql -r -d /mysqldata -s /sbin/nologin mysql
# chown -R mysql:mysql /mysqldata
# tar xf mysql-5.5.33.tar.gz
# cd mysql-5.5.33
# cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/mysqldata -DSYSCONFDIR=/etc -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DWITH_SSL=system -DWITH_ZLIB=system -DWITH_LIBWRAP=0 -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci
# make
# make install
4. mysql服务器初始化
//创建my.cnf配置文件
# cd /usr/local/mysql
# cp support-files/my-large.cnf /etc/my.cnf
# echo "datadir = /mysqldata" >> /etc/my.cnf
//创建服务脚本
# cp support-files/mysql.server /etc/init.d/mysqld
# chmod +x /etc/init.d/mysqld
# chkconfig --add mysqld
# chkconfig mysqld on
//初始化mysql系统数据库
# scripts/mysql_install_db --user=mysql --datadir=/mysqldata
//修改环境变量
# echo "export PATH=$PATH:/usr/local/mysql/bin" > /etc/profile.d/mysql.sh
# . /etc/profile.d/mysql.sh
5. 修改默认密码
# service mysqld start
# mysql -uroot -p //回车,默认为空密码
mysql>
方法一:
mysql> SET PASSWORD FOR ‘root‘@‘localhost‘ = PASSWORD(‘12345‘);
方法二:
mysql> UPDATE user SET password = PASSWORD(‘12345‘) WHERE user = ‘root‘;
mysql> FLUSH PRIVILEGES;
方法三:
# mysqladmin -uroot -hlocalhost password ‘new12345‘ -p
# mysqladmin -uroot -hlocalhost -p flush-privileges
6. 删除匿名用户
mysql> select user,host,password from mysql.user;
+------+-----------------------+-------------------------------------------+
| user | host | password |
+------+-----------------------+-------------------------------------------+
| root | localhost | *96073409CD134870AF004F84332F73924C906E9A |
| root | localhost.localdomain | |
| root | 127.0.0.1 | |
| root | ::1 | |
| | localhost | |
| | localhost.localdomain | |
+------+-----------------------+-------------------------------------------+
6 rows in set (0.00 sec)
//删除最后两行
mysql> drop user ‘‘@‘localhost‘;
mysql> drop user ‘‘@‘localhost.localdomain‘;
本文出自 “虎虎生威” 博客,请务必保留此出处http://tobeone.blog.51cto.com/817917/1575789
标签:mysql
原文地址:http://tobeone.blog.51cto.com/817917/1575789