无法从CentOS 5的本地主机连接到MySQL

我有一个全新的VPS安装Centos 5.5,MySQL似乎无法parsing关键字'本地主机' – 如果我使用127.0.0.1,而不是它的工作正常。 我检查了/ etc / hosts文件,如下所示:

# Auto-generated hostname. Please do not remove this comment. xxx.xxx.xxx.xxx 224136.xxxxxxxx.com localhost 224136 224136 localhost.localdomain 127.0.0.1 localhost 

(我自己添加了最后一行)…但仍然无法识别localhost关键字。 例如,当我尝试使用Navicat通过SSH隧道连接到我的MySQL服务器时,出现错误:

 1130 - Host 'xxx.xxx.xxx.xxx' is not allowed to connect to this MySQL server 

任何想法可能是什么问题,谢谢

只是为了统治MySQL是罪魁祸首,请确保您拥有root @ localhost和[email protected]作为MySQL中定义的单独用户。

执行以下操作以确保root用户可以进入MySQL:

 SHOW GRANTS FOR 'root'@'localhost'; SHOW GRANTS FOR 'root'@'127.0.0.1'; 

root @ localhost通过mysql.sock文件连接

[email protected]通过TCP / IP连接

在你解决networking问题之前,你可能需要使用mysql客户端的–protocol选项来指定协议(tcp,socket,pipe,memory)

/ etc / hosts的第一行已经有localhost。 你应该从'xxx.xxx.xxx.xxx'开始的行中删除localhost