MySQL 8.0.5开启远程连接
连接数据库
mysql -uroot -p
2.在mysql8版本更新用户密码需要加入加密规则 wtth mysql_native_password
# 查看mysql插件信息
show plugins;
# 选择mysql库
use mysql;
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '新密码';
![在这里插入图片描述](https://ucc.alicdn.com/images/user-upload-01/20201109233557170.png#pic_center)
###3.修改root用户的host为'%'
# 从user表中列出所有user,host 此时显示的root 用户的host为 localhost
select user,host from user;
# 修改root用户的ip地址为%
update user set host='%' where user = 'root';
# 从user表中列出所有user,host 此时显示的root 用户的host为 %
# 刷新权限信息使更新生效
flush privileges;
# 退出mysql
exit;
4.关闭防火墙
查看防火墙状态信息
systemctl status firewalld
# 关闭防火墙
systemctl stop firewalld
#永久关闭防火墙(开机启动时不再启动)
systemctl disable firewalld