——表更表
update user set host = ’%’ where user = ’root’;
grant all privileges on . to root@’%’ identified by “password”;
⚠️⚠️BUT
远程连接mysql仍能出现Can’t connect to MySQL server on (111 “Connection refused”)
或者
telnet xxxxxxx 3306
Trying xxxxxxx…
telnet: connect to address xxxxx: Connection refused
telnet: Unable to connect to remote host
这里有坑。。。。。。
我一直在看防火墙,安全组等这些,都开放了3306,但是一直telnet不通,尴尬啊。
解决方案
先查mysql有没有对应3306端口(无语,我就没有查)
登陆mysql以后:使用命令show global variables like ‘port’;查看端口号
mysql> show global variables like ‘port’;
+—————+——-+
| Variable_name | Value |
+—————+——-+
| port | 3306 |
+—————+——-+
1 row in set (0.00 sec)
如果是的话,然后再回去看是否开放3306端口和安全组等,推荐博文:
https://blog.csdn.net/Ivy___/article/details/54708972
如果不是,修改/etc/my.cnf
[mysqld]
port=3306
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
symbolic-links=0
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
二:密码加密校验
Authentication plugin ‘caching_sha2_password’ cannot be loaded: dlopen(/usr/local/mysql/lib/plugin/caching_sha2_password.so, 2):
表明:这种密码加密方式【caching_sha2_password】,客户端不支持
解决方案:
ALTER USER ‘root’@’%’ IDENTIFIED WITH mysql_native_password BY ‘newpassword’;
閱讀更多 程序員Nicky 的文章