在 centos 6.x 服务器 LAMP 中远程连接到 Mysql

Connect to Mysql remotely in centos 6.x server LAMP

尽管我已经尝试了论坛中建议的所有方法,但我仍然无法远程连接到 MySQL。 这是我的 my.cnf 文件:

[mysqld]
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

我也试过添加行 bind-address = 0.0.0.0 但仍然不起作用。 然后我删除了它,因为我更喜欢保留我的网络服务器的默认配置,因为我已经读过,如果没有指定,默认情况下它是 0.0.0.0。

我打开了端口 3306,您可以从我的 webmin 模块中看到: Linux IPTables Firewall

我已经创建了名为 'michele' 的 MySQL 帐户,您可以从我的 webimn 模块 User Permissions

中看到

我还授予 michele 任何数据库的权限 Database Permissions

并授予任何主机所有权限Host Permissions

为了测试我的远程连接,我尝试从 MySQL 连接到 excel。那是错误 error MySQL fro excel

It is impossible to stabilize the connection. Incorrect response of the connected party after the time interval or no response from the connected host MY-IP-SERVER:3306

另外我想通知你,这是我第二次尝试远程连接。在我的第一次,我做到了!对于不处理远程连接的问题,我需要重新初始化我的服务器,我在这里。

我第一次记得在某些配置文件中我在某行中添加了 # 以进行注释,但我不记得是哪一行以及它是否解决了我的问题。请帮帮我,我要疯了!

米歇尔

我做到了! 问题出在 ipTable 规则上: REJECT 拒绝 icmp-host-prohibited rule

所以为了解决问题我删了

在我的服务器上 shell 具有 root 权限:

 # sudo iptables -L --line-numbers

find the id rule 然后删除它:

 # sudo iptables -D INPUT 10