此贴承接上一篇安装mysql8.0
输入防火墙开放端口命令
firewall-cmd --zone=public --add-port=3306/tcp --permanent
--add-port=后面接需要开放的端口
刷新防火墙
firewall-cmd --reload
登录mysql
use mysql;
select host, user, authentication_string, plugin from user;
查看user表的root用户Host字段是localhost,说明root用户只能本地登录,现在把他改成远程登录
update user set host='%' where user='root';
更改加密方式
ALTER USER 'root'@'localhost' IDENTIFIED BY 'password' PASSWORD EXPIRE NEVER;
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
刷新权限
FLUSH PRIVILEGES;