I'm trying to connect to mysql using the command
mysql -h 127.0.0.1
It comes up with the error
ERROR 1045 (28000): Access denied for user 'root'@'mydomain.com' (using password: NO)
Why is 127.0.0.1 being converted into my domain name, and how can I fix it?
However, it does work if I don't specify a host (and by extension, if 'localhost' is specified).
Edit: It seems it resolves to the domain name when using TCP, so it also fails when using
mysql -h localhost --protocol=TCP
Edit2: When I use skip-name-resolve I get a similar output except mydomain.com is replaced with x.x.x.x which is the public IP of mydomain.com.
127.0.0.1 mydomain.comin your/etc/hostsfile? – garethTheRed Jul 04 '14 at 08:51Access deniedor it still hasmydomain.comin the user name? If it's the latter and you definitely have removed your hostname from/etc/hoststhen DNS must be misconfigured formysqlto be able to reverse lookup127.0.0.1to your hostname. – garethTheRed Jul 04 '14 at 11:11/etc/hosts– Ben Jul 04 '14 at 11:32telnet 127.0.0.1 3306which shows that mysqld is listening and accessible. I can also explicitly add a'root'@'mydomain.com'user and login to mysql. – Ben Jul 04 '14 at 12:23mysql -h 127.0.0.1are not seen as coming from localhost or 127.0.0.1 but something else (in this case the hostname of (or) the public IP) – Ben Jul 04 '14 at 12:53iptablesissue but I've tried flushing unnecessary rules etc to no avail. – Ben Jul 04 '14 at 13:29actually works as intended.
– Jul 04 '14 at 06:35