MySQL 8.0.5开启远程连接

  1. 连接数据库
mysql -uroot -p	

hWMmml

  1. 在mysql8版本更新用户密码需要加入加密规则 wtth mysql_native_password

    注明:mysql8共提供了3种认证方式

    # 查看mysql插件信息
    show plugins	
    

    i8VgSt

    • Mysql_native_password mysql8.0之前默认使用的认证插件 如果要使用 3m mha
    • Caching_sha2_password mysql8.0默认使用认证插件 好处在于使用缓存,可加快认证建立连接速度
    • Sha256_password
alter user 'root'@'localhost' identified with mysql_native_password by '*****'
  1. 修改root用户的host为'%'
# 选择mysql库
use mysql;
# 从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;

ic3ENU

  1. 关闭防火墙

    # 查看防火墙状态信息
    systemctl status firewalld
    
    #关闭防火墙
    systemctl stop firewalld
    
    #永久关闭防火墙(开机启动时不再启动)
    systemctl disable firewalld
    
  2. 使用navicate测试连接

    E5aveL

原文地址:https://www.cnblogs.com/shine-rainbow/p/13170547.html