无法连接到MySQL服务器错误111 [英] Can't connect to MySQL server error 111
问题描述
我在linux机器IP = 192.168.1.100上安装了mysql服务器,但是当我尝试连接到该IP时,它总是报错(111).但使用localhost并可以使用127.0.0.1.
I installed mysql server on linux box IP = 192.168.1.100 but when i try to connect to this IP it alway error(111). but use localhost and 127.0.0.1 is OK.
beer@beer-laptop# ifconfig | grep "inet addr"
inet addr:127.0.0.1 Mask:255.0.0.0
inet addr:192.168.1.100 Bcast:192.168.1.255 Mask:255.255.255.0
beer@beer-laptop# mysql -ubeer -pbeer -h192.168.1.100
ERROR 2003 (HY000): Can't connect to MySQL server on '192.168.1.100' (111)
beer@beer-laptop# mysql -ubeer -pbeer -hlocalhost
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 160
Server version: 5.1.31-1ubuntu2 (Ubuntu)
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql>
beer@beer-laptop# mysql -ubeer -pbeer -h127.0.0.1
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 161
Server version: 5.1.31-1ubuntu2 (Ubuntu)
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql>
从另一台计算机连接它也会出现错误111.
Connect from another machine it also error 111.
another@another-laptop# mysql -ubeer -pbeer -h192.168.1.100
ERROR 2003 (HY000): Can't connect to MySQL server on '192.168.1.100' (111)
在这种情况下,使用localhost/127.0.0.1和192.168.1.100有何区别. 我不知道如何从另一台计算机连接到该数据库.
How difference between use localhost/127.0.0.1 and 192.168.1.100 in this case. I don't know how to connect to this database from another machine.
请帮助. 谢谢.
推荐答案
这可能意味着您的MySQL服务器仅在监听localhost接口.
It probably means that your MySQL server is only listening the localhost interface.
如果您有这样的行:
bind-address = 127.0.0.1
在您的 my.cnf
配置文件中,应为它们添加注释(在#的开头添加#行),然后重新启动MySQL.
In your my.cnf
configuration file, you should comment them (add a # at the beginning of the lines), and restart MySQL.
sudo service mysql restart
当然,要做到这一点,您必须是服务器的管理员.
Of course, to do this, you must be the administrator of the server.
这篇关于无法连接到MySQL服务器错误111的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!