这个问题与以下问题有关:
我正在本地机器上配置一个新的 MySQL (5.1) 服务器。我需要提供对数据库的远程访问。我做了以下步骤:
bind-address
在 my.cnf 中评论:# bind-address = 192.168.1.3
授予权限:
GRANT ALL PRIVILEGES ON *.* TO 'nickruiz'@'%' IDENTIFIED BY PASSWORD 'xxxx';
- 在路由器上设置端口转发(TCP 和 UDP,端口 3306、192.168.1.3)
为防火墙配置 iptables
sudo iptables -I INPUT -p udp --dport 3306 -j ACCEPT sudo iptables -I INPUT -p tcp --dport 3306 --syn -j ACCEPT sudo iptables-save
重启mysql服务器
sudo /etc/init.d/mysql restart
测试时,我得到以下信息:
局域网:
mysql -h 192.168.1.3 -u nickruiz -p
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 95
Server version: 5.1.63-0ubuntu0.11.04.1 (Ubuntu)
偏僻的:
mysql -h 1xx.xx.4.136 -u nickruiz -p
ERROR 2003 (HY000): Can't connect to MySQL server on '1xx.xx.4.136' (111)
显然有什么问题阻止了我使用我的全球 IP 地址。
笔记:
- 我尝试在同一台机器上测试远程连接,也尝试通过远程机器上的 SSH 测试远程连接。
- 我不确定我的 ISP 是否给了我一个静态 IP。
有任何想法吗?
更新: telnet 似乎没有工作。
telnet 192.168.1.3 3306
Trying 192.168.1.3...
Connected to 192.168.1.3.
Escape character is '^]'.
E
5.1.63-0ubuntu0.11.04.1,0g8!:@pX;]DyY0#\)SIConnection closed by foreign host.