连接远程mysql服务器(CentOS)失败,我尝试了很多方法但没有帮助。
我可以成功通过ssh访问远程主机,并且3306端口正在监听:
[root@fabulous ~]# netstat -lntp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 9979/mysqld
我已关闭了iptables:
[root@fabulous ~]# service iptables stop
iptables: Setting chains to policy ACCEPT: filter [ OK ]
iptables: Flushing firewall rules: [ OK ]
iptables: Unloading modules: [ OK ]
远程服务器上的Mysql客户端运行良好,并且允许在每个主机上进行访问:
mysql> select user,host from user;
+-------+--------------------+
| user | host |
+-------+--------------------+
| root | % |
| root | 127.0.0.1 |
| root | fabulous.ma2oo.com |
| root | localhost |
+-------+--------------------+
4 rows in set (0.00 sec)
MySQL的全局配置:
[root@fabulous ~]# vi /etc/my.cnf
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
[mysql]
default-character-set=utf8
然而,当我在我的Windows笔记本电脑上使用Navicat访问MySQL服务器时,错误信息是:
2003 - Can't connect to MySql server on 'XX.XX.XX.XX' (10038)
当我使用telnet访问该服务器上的相应端口时,出现了以下错误信息:
C:\Users\shijunji>telnet 107.170.239.240 3306
Connecting To 107.170.239.240...Could not open connection to the host, on port 3306: Connect failed
有人知道它或者能告诉我如何找到有用的日志吗? 提前致谢。