在Ubuntu9.10上使用sudo apt-get install mysql-server-5.0 安装了mysql,在外面访问不了mysql,但是在Ubuntu上访问是没有问题的。
于是开始查找原因:
3306端口是不是没有打开?
使用nestat命令查看3306端口状态:
~# netstat -an | grep 3306
tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN
从结果可以看出3306端口只是在IP 127.0.0.1上监听,所以拒绝了其他IP的访问。
解决方法 :修改/etc/mysql/my.cnf文件。 打开 文件,找到下面内容:
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
bind-address = 127.0.0.1
把上面这一行注释掉或者把127.0.0.1换成合适的IP,建议注释掉。
重新启动后,重新使用netstat检测:
~# netstat -an | grep 3306
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN
问题解决