0

I have a fresh install of Centos 5.5 on a new VPS and MySQL seems unable to resolve the keyword 'localhost' - if I use 127.0.0.1 instead it works fine. I checked the /etc/hosts file which is as follows:

# 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 

(I added the last line myself)...but still the localhost keyword isn't recognised. For example when I try to connect to my MySQL server using Navicat over SSH tunnel I get an error:

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

any ideas what might be the problem, thanks

4
  • Could you please show us 'host -a localhost' or equivalent? (not sure about the command line keys in your OS) Commented May 19, 2011 at 12:51
  • The 1130 error message you posted doesn't seem to have anything to do with a name resolution issue, it merely states that a given IP doesn't have access to MySQL? What happens when you run 'ping localhost'? Commented May 19, 2011 at 13:49
  • [root@224136 ~]# host -a localhost Trying "localhost" Host localhost not found: 3(NXDOMAIN) Received 102 bytes from xxx.xxx.xxx.xxx#53 in 0 ms Commented May 20, 2011 at 14:12
  • [root@224136 ~]# ping localhost PING 224136.xxxx.com (xxx.xx.xxx.xx) 56(84) bytes of data. 64 bytes from 224136.xxxxx.com (xxx.xx.xxx.xx): icmp_seq=1 ttl=64 time=0.030 ms Commented May 20, 2011 at 14:14

2 Answers 2

1

Just for the sake of ruling MySQL is the culprit, please make sure you have root@localhost and [email protected] as separate users defined in MySQL.

Do the following to make sure root users can come into MySQL:

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

root@localhost connects via the mysql.sock file

[email protected] connects via TCP/IP

Until you get the networking issues straightened out, you may want to use the --protocol option of the mysql client to specify the protocol (tcp,socket,pipe,memory)

1
  • GRANT ALL PRIVILEGES ON . TO 'root'@'localhost' IDENTIFIED BY PASSWORD 'xxxxxxxxx' WITH GRANT OPTION GRANT ALL PRIVILEGES ON . TO 'root'@'127.0.0.1' IDENTIFIED BY PASSWORD 'xxxxxxxxx' WITH GRANT OPTION Commented May 20, 2011 at 14:09
0

You already have localhost on first line of /etc/hosts. You should remove localhost from line beginning with 'xxx.xxx.xxx.xxx'

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.