centos8 mysql8的远程访问

1 查看参数

1.1查看端口号

show global variables like 'port'

1.2 查看用户名

select user,host from user;

2 开放root的远程访问端口

2.1 修改root的host

update user set host="%" where user="root";

再查看

select user,host from user;

2.2 开放端口

grant all privileges on *.* to 'root'@'%' with grant option;

2.3 修改插件plugin

select host,user,plugin,authentication_string from mysql.user;

ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '你的密码';

再次查看

select host,user,plugin,authentication_string from mysql.user;

2.4 立即生效

flush privileges;​

3 远程访问

 本人遇到的错误总结

错误1 Can't connect to Mysql server on....(10060)

是因为没有开放远程端口  参考 https://www.cnblogs.com/wintest/p/11442920.html 

https://blog.csdn.net/wrs120/article/details/78771468

错误2 1251-Client does not support authentication protocol requested by server

是因为插件问题,参考这篇文章:https://my.oschina.net/u/3295928/blog/1811804

参考

其他人总结

原文地址:https://www.cnblogs.com/polax/p/13908469.html