1. wget https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-community-server-8.0.18-1.el8.x86_64.rpm
2.yum localinstall mysql-community-server-8.0.18-1.el8.x86_64.rpm
3.yum install -y mysql-commiunity-server
4.启动mysql服务:systemctl start mysqld
检查mysql状态:systemctl status msyqld
5.查找mysql root用户的初始密码:grep "password" /var/log/mysqld.log
6.进入数据库:mysql -uroot -p, 输入初始密码;
7.修改root密码:ALTER USER ‘root‘@‘localhost‘ IDENTIFIED BY ‘[email protected]‘;
8.配置root远程登陆:
use mysql; #使用mysql
UPDATE user SET Host=‘%‘ WHERE User=‘root‘; #设置账号
flush privileges;
9.windows使用navicat for mysql连接数据库,报错:1251...;这种错误的原因是mysql8之前版本的加密规则是mysql_native_password,而在mysql8之后,加密规则是caching_sha2_password;
解决方法:将mysql用户登录密码加密规则还原成mysql_native_password;
ALTER USER ‘root‘@‘%‘ IDENTIFIED BY ‘[email protected]‘ PASSWORD EXPIRE NEVER;
ALTER USER ‘root‘@‘%‘ IDENTIFIED WITH mysql_native_password BY ‘[email protected]‘;
FLUSH PRIVILEGES; #刷新权限;
这样Windows的navicat 就可以连接mysql了