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

Xoundboy
  • 603
  • 1
  • 10
  • 21
  • Could you please show us 'host -a localhost' or equivalent? (not sure about the command line keys in your OS) – etranger May 19 '11 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'? – Lucky Luke May 19 '11 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 – Xoundboy May 20 '11 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 – Xoundboy May 20 '11 at 14:14

2 Answers2

1

Just for the sake of ruling MySQL is the culprit, please make sure you have root@localhost and root@127.0.0.1 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

root@l127.0.0.1 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)

RolandoMySQLDBA
  • 16,544
  • 3
  • 48
  • 84
  • 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 – Xoundboy May 20 '11 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'

AlexD
  • 8,747
  • 2
  • 29
  • 38