我有一个在debian上运行的mysql服务器( Server version: 5.5.60-0+deb8u1 (Debian)
). 一切正常,直到重新启动服务器。现在我只能通过localhost连接到mysql服务器,而通过127.0.0.1无法工作: $ mysql -h 127.0.0.1 -u root -p
给了我 ERROR 2013 (HY000): Lost connection to MySQL server at 'reading initial communication packet', system error: 0
我在防火墙中打开了3306端口,服务器似乎正在侦听3306:
$ netstat -plnt
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN 20877/mysqld
使用telnet连接到3306似乎也不起作用(对于localhost和127.0.0.1):
$ telnet 127.0.0.1 3306
Trying ::1...
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
Connection closed by foreign host.
在我的 my.cnf
我有 bind-address = 127.0.0.1
,这应该不是问题。。。
在 /etc/hosts
有这些线
127.0.0.1 localhost
::1 localhost ip6-localhost ip6-loopback
我就是找不到错误,你有什么想法吗?
1条答案
按热度按时间1wnzp6jl1#
原来tcp Package 器拒绝了与127.0.0.1的连接。通过添加解决
mysqld: 127.0.0.1
到/etc/hosts.allow
-文件。