On Sun, Nov 07, 2004 at 12:17:26AM -0000, Mark Rogers wrote:
Chris Green writes:
However if I then say 'mysql -uchris' and try 'use fred' I still get:- ERROR 1044: Access denied for user: '@localhost' to database 'fred'
If, on the other hand, I do exactly as above except I set host to 'Local' then user chris works as expected.
Now that I think more about this, I recall that "any host" specifically excludes "localhost". I'm sure there's a good reason too, but it escapes me now. However, I did find, from http://dev.mysql.com/doc/mysql/en/Access_denied.html
.. the following which I think is relevant:
If you can't figure out why you get Access denied, remove from the user table all entries that have Host values containing wildcards (entries that contain `%' or `_'). A very common error is to insert a new entry with Host='%' and User='some_user', thinking that this will allow you to specify localhost to connect from the same machine. The reason that this doesn't work is that the default privileges include an entry with Host='localhost' and User=''. Because that entry has a Host value 'localhost' that is more specific than '%', it is used in preference to the new entry when connecting from localhost! The correct procedure is to insert a second entry with Host='localhost' and User='some_user', or to delete the entry with Host='localhost' and User=''. After deleting the entry, remember to issue a FLUSH PRIVILEGES statement to reload the grant tables.
As a general rule, just think of localhost and other hosts separately.
Ah, yes, I think that would explain what I'm seeing, thanks. I do want to have the 'Any Host' access as this is on a small home network and I want to allow other computers to access that database. It's behind a NAT firewall so the outside world won't be able to see it.