principlesqlMinor
MySQL: 'user'@'hostname' vs 'user'@'IPaddress'
Viewed 0 times
ipaddressusermysqlhostname
Problem
I needed an user to be able to log in on our MySQL server 5.6 from machine foobarhost, IP 10.11.12.13.
Therefore I created a user
My question: how does MySQL handle hostnames vs IP addresses concerning users?
MySQL sorts the user table before checking for a match, using IP addresses and hostnames as the most-specific values to match to. However, the docs do not specify what takes precedence - hostname or IP. Does MySQL attempt a hostname resolution and, if it fails, performs a check on the IP?
What is the recommended usage for the user table: specify only IP addresses, hostnames, or both (as I did in the example above)?
Therefore I created a user
'joe'@'foobarhost' but he was unable to log in. I had to create an user 'joe'@'10.11.12.13' and this time worked fine.My question: how does MySQL handle hostnames vs IP addresses concerning users?
MySQL sorts the user table before checking for a match, using IP addresses and hostnames as the most-specific values to match to. However, the docs do not specify what takes precedence - hostname or IP. Does MySQL attempt a hostname resolution and, if it fails, performs a check on the IP?
What is the recommended usage for the user table: specify only IP addresses, hostnames, or both (as I did in the example above)?
Solution
I had this problem before, and after long investigation I found out sometimes MySQL can not resolve any issue related to
then save and close ( note Windows will require reboot before taking any effect), you may need to add the following parameters
DNS by default, so I did the following: edited hosts file ( can be found under Linux /etc/hosts, for Windows C:\Windows\System32\drivers\etc\hosts) and added ip and hostname for the client machine,in your example its 10.11.12.13 foobarhostthen save and close ( note Windows will require reboot before taking any effect), you may need to add the following parameters
--skip-name-resolve and\or --skip-host-cache .Code Snippets
10.11.12.13 foobarhostContext
StackExchange Database Administrators Q#101265, answer score: 5
Revisions (0)
No revisions yet.