Can't connect to remote MySQL server with error 61

0.问题描述
通过Navicate连接远程MySQL服务器时出现了Can’t connect to remote MySQL server with error 61问题,通过查找stackoverflow找到下面的解决方案,记录一下。

1.检查监听状态

netstat -tulpen
//如果3306端口没有sql服务,或者mysql服务器仅监听本地端口localhost 127.0.0.1,需要将配置文件中的bind-address=127.0.0.1改为bind-address = 0.0.0.0

Can't connect to remote MySQL server with error 61_第1张图片

2.修改配置文件

vi /etc/mysql/my.cnf   //MySql 5.7以前版本
或vi /etc/mysql/mysql.conf.d/mysqld.cnf  //MySql 5.7及以后版本
bind-address = 0.0.0.0

Can't connect to remote MySQL server with error 61_第2张图片

3.修改该用户的权限

GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'%'IDENTIFIED BY 'mypassword' WITH GRANT OPTION;
FLUSH PRIVILEGES;

Host的值是%时,表示可以通过任何ip连接的该mysql服务器
Can't connect to remote MySQL server with error 61_第3张图片
4.重启mysql

/etc/init.d/mysql restart

整理自 Stackoverflow

你可能感兴趣的:(learning,mysql,bind-addre,can-t-conn,error-61)