CentOS7 安装 MySQL 5.7.10

时间:2021-11-14 11:04:48

卸载冲突的rpm包:
rpm -qa|grep mariadb
rpm -e --nodeps mariadb-libs-5.5.41-2.el7_0.x86_64

安装:
rmp -ivh mysql-community-common-5.7.10-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-5.7.10-1.el7.x86_64.rpm
rpm -ivh mysql-community-devel-5.7.10-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-5.7.10-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-5.7.10-1.el7.x86_64.rpm

初始化:
mysqld --initialize --user=mysql

启动:
systemctl start mysqld
systemctl status mysqld

连接:
vim /usr/log/mysqld.log(找到随机生成的密码)
mysql -u root -p

修改密码:
ALTER USER 'root'@'localhost' identified by 'mYsqL$%123';

注意密码必须包含数字、大写字母、小写字母、特殊字符,如果你设置的密码过于简单,会得到一个错误提示。

参考:
http://dev.mysql.com/doc/refman/5.7/en/linux-installation-rpm.html
http://jingyan.baidu.com/article/93f9803f010d8fe0e56f555e.html