当我尝试使用命令行或任何其他 mysql 客户端(如 phpmyadmin)连接远程 MySQL 服务器时mysql -h <remote-ip> -u any_existing_users -p
,它不起作用,错误提示是
ERROR 2003 (HY000) Can't connect to MySQL server on '<remote-ip>' (61)
但是,当我尝试ssh <remote-ip>
通过 本地连接 MySQL时mysql -u root -p
,没有问题。
以下是用户表的一部分(SELECT User, Host FROM mysql.user;
):
+------------------+----------------+
| User | Host |
+------------------+----------------+
| root | % |
| other_users | <remote-ip> |
| root | localhost |
+------------------+----------------+
所以有什么问题?
答案1
您是否已在 mysql 服务器中启用网络功能,请再次验证,如果没有,请按照以下步骤操作
Edit /etc/my.cnf, run:
# vi /etc/my.cnf
Once file opened, locate line that read as follows
[mysqld]
Make sure line skip-networking is commented (or remove line) and add following line
bind-address=YOUR-SERVER-IP