无法连接到MySQL服务器错误111
我在Linux上安装了mysql服务器IP = 192.168.1.100,但是当我尝试连接到这个IP时,它总是报错(111)。但使用localhost和127.0.0.1即可。无法连接到MySQL服务器错误111
[email protected]# 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 [email protected]# mysql -ubeer -pbeer -h192.168.1.100 ERROR 2003 (HY000): Can't connect to MySQL server on '192.168.1.100' (111) [email protected]# 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> [email protected]# 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
[email protected]# 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之间的差异。 我不知道如何从另一台机器连接到这个数据库。
请帮忙。 谢谢。
这可能意味着你的MySQL服务器只能监听localhost接口。
如果你有这样的台词:
skip-networking
bind-address = 127.0.0.1
在你my.cnf
configuration file,你应该评论他们(在行的开头加#),并重启MySQL。
当然,要做到这一点,您必须是服务器的管理员。
111表示连接被拒绝,这反过来意味着你的mysqld只能听到接口localhost
。
要更改它,您可能需要查看my.cnf
文件的mysqld
部分中的bind-address
值。
如果所有以前的答案没有给出任何解决方案, 你应该检查你的用户权限。
如果你能为root
登录到MySQL 那么你应该补充一点:
CREATE USER 'root'@'192.168.1.100' IDENTIFIED BY '***';
GRANT ALL PRIVILEGES ON * . * TO 'root'@'192.168.1.100' IDENTIFIED BY '***' WITH GRANT OPTION MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0 ;
然后再次尝试使用mysql -ubeer -pbeer -h192.168.1.100
连接。它应该工作。
如果您正在运行cPanel/WHM,请确保IP在防火墙中列入白名单。您还需要将该IP添加到您尝试连接的cPanel帐户中的远程SQL IP列表。
一个很好的“告诉”,看看它是否导致错误的防火墙是,它将需要很长一段时间才能返回错误。如果MySQL导致问题,响应应该是非常即时的。 –
显然,他没有'skip-networking'这行;-) –
如何知道mysql my.cnf位置:http://stackoverflow.com/questions/2482234/how-to-know-mysql-my- cnf-location –
但是当你可以从mysql工作台连接到它时会发生什么?我也有同样的问题。 –