> CentOS > CentOS教程 >

CentOS下 rpm安装mysql总结

RPM安装MySQL 5.7
-----------------------版本1 centos7-----------------------
1.卸载mariadb.lib
2.顺序:common、lib、client、server(/var/log/mysqld.log密码)
3.chown -R mysql:mysql /data/mydata ;
  mysqld  [--user=mysql] --datadir=/data/mydata --initialize
  (mysqld --verbose --help 含有各种变量和选项)
4.vi /etc/my.cnf
5.systemctl start mysqld.service
6.mysql_secure_installation --user=root --password='dfsfsdfs'


-----------------------版本2 centos6-------------------------
1.卸载其他版本的mysql,必要时用rpm -e MySQL-*** --nodeps
2.顺序:common、lib、client、server(/root/.mysql_secret or /var/log/mysqld.log)
3.chown -R mysql:mysql /data/mysqldata
  mysqld --user=mysql --datadir=/data/mysqldata --initialize
4.vi /etc/my.cnf
5.chkconfig --add mysqld    chkconfig mysqld --level 35 on
6.mysql_secure_installation --user=root --password=


--------------密码安全认证插件-------------
1.show plugins;
2.在my.cnf的mysqld中添加validate_password=off
3.重启mysqld


-------------------密码---------------------
set password for 'root'@localhost = PASSWORD('chenxing');


-------------------mysql系统日志时间晚于系统8个小时的问题---------------
将log_timestamps=SYSTEM即可


-------------------其他操作---------------------
1.授权:GRANT SELECT,UPDATE,INSERT,DELETE on *.* to yongfu_a@'localhost';
  取消授权:REVOKE SELECT,UPDATE,INSERT,DELETE on *.* from yongfu_a@'localhost';
2.删除一个用户:drop user 'root'@'localhost';
3.添加用户:create user 'root'@"localhost' identified by 'cxx';
4.设置密码:set password for 'root'@'localhost' = PASSWORD("cxx");

(责任编辑:IT)