Just an FYI: if you want to grant access to a local MySQL database,
you need to explicitly state that when issuing a grant statement.
Using 'foo'@'% is not enough, even though '%' is supposed to mean any
host.  You need to also issue a grant with 'foo'@'localhost'.

Here's a transcript of a recent session.  Note what happens when I try
to connect the first time as foo to localhost.

$ mysql -h localhost -u root -p123456 -e 'show databases ;'
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
+--------------------+

$ mysql -h localhost -u root -p123456 -e "grant ALL privileges on *.*
to 'foo'@'%' identified by 'foo' ; "

$ mysql -h localhost -u foo -pfoo -e 'show databases ;'
ERROR 1045 (28000): Access denied for user 'foo'@'localhost' (using
password: YES)

$ mysql -h localhost -u root -p123456 -e "grant ALL privileges on *.*
to 'foo'@'localhost' identified by 'foo' ; "

$ mysql -h localhost -u foo -pfoo -e 'show databases ;'
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
+--------------------+

At face value (i.e. after reading the GRANT manual page[1]) one would
think that 'foo'@'%' would allow user foo to connect from anywhere.
Unfortunately, that is not the case because of the sorting rules MySQL
uses to process permissions[2].  So you must include localhost.  Ah,
the quirks of systems.

[1] http://dev.mysql.com/doc/refman/5.1/en/grant.html
[2] http://dev.mysql.com/doc/refman/5.1/en/adding-users.html

Regards,
- Robert

--~--~---------~--~----~------------~-------~--~----~
Central West End Linux Users Group (via Google Groups)
Main page: http://www.cwelug.org
To post: [email protected]
To subscribe: [email protected]
To unsubscribe: [email protected]
More options: http://groups.google.com/group/cwelug
-~----------~----~----~----~------~----~------~--~---

Reply via email to