I'm going crazy to solve this. I have a mysql installation (on machine db.example.org
) which doesn't resolve a given hostname. I gave privileges using hostnames i.e.
GRANT USAGE ON *.* TO 'user'@'host1.example.org' IDENTIFIED BY PASSWORD 'secret'
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, INDEX ON `my_database`.* TO 'user'@'host1.example.org'
However when I try to connect using mysql -u user -p -h db.example.org
I obtain
ERROR 1045 (28000): Access denied for user 'user'@'192.168.11.244' (using password: YES)
I already checked for correct name resolution in the dns system:
$ dig -x 192.168.11.244
;; ANSWER SECTION:
244.11.168.192.in-addr.arpa. 68900 IN PTR host1.example.org.
I've also checked for skip-name-resolve
option in mysql variables in fact if I can access from another machine on the same subnet using hostname privileges.
The only difference is that host1.example.org
and db.example.org
point the same ip on the same machine i.e. both db.example.org
and host1.example.org
have ip 192.168.11.244. In this way all the applications using that database can use the name db.example.org
and we can move the data on other hosts (if needed) just by changing the dns record, leaving the application code unchanged.
What should I do to solve this or at least to understand what's happening?
Just to make sure, have you tried running FLUSH PRIVILEGES ?
After a couple of days the problem is gone... I tried again, and now it does work. Maybe it was a temporary dns failure or a cache problem (I executed the flush hosts command more than once). Anyway the problem is solved.