ubantu mysql无法远程连接问题

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/wb96a1007/article/details/82903154

1、我们先看看,常规套路:

mysql -u root -p

mysql> update user set host = '%' where user = 'root';

/etc/init.d/mysqld restart

一般来说,以上就应该够了。(可能有些要关防火墙)

但ubantu:18.04+mysql:5.7就不行了,还得用几招。

2、查看/etc/mysql/my.cnf 内容,如与以下不符,直接替换

root@ubuntu:~# cat /etc/mysql/my.cnf 
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
# bind-address           = 127.0.0.1
 

3、修改密码

ALTER USER 'root'@'%' IDENTIFIED BY 'pwd' PASSWORD EXPIRE NEVER;
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'pwd';
FLUSH PRIVILEGES;

4、OK了

猜你喜欢

转载自blog.csdn.net/wb96a1007/article/details/82903154
今日推荐