tags:

views:

66

answers:

3

Using this command

GRANT ALL PRIVILEGES ON *.* to 'brian'@'%' identified by 'password';

I try to login with:

 mysql -u brian -ppassword

The error is:

ERROR 1045 (28000): Access denied for user 'brian'@'localhost' (using password: YES)

I am doing this as root and I did try to flush privileges.

I tried this with countless users but it does not seem to work. I can create a user with no password and login works. Command line and from phpmyadmin

Also check to see if the user was in mysql.user which it is.

Show grants for brian shows:

| GRANT ALL PRIVILEGES ON *.* TO 'brian'@'%' IDENTIFIED BY PASSWORD '*2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19' |
+2  A: 

Try using

mysql -u brian -p

And then type the password when it prompts you

Chris Thompson
That isn't any different, for purposes of testing authentication, from what he's doing.
chaos
Correct, I've just always had issues passing the password directly as a parameter. It was just a thought
Chris Thompson
+1  A: 

You probably have this perpetual MySQL problem where one of the default users in the user table is '' @ localhost, which winds up denying all localhost users later in the table. What I would do is mysqldump the mysql database and look for this entry in the User table; if found, delete it and flush privileges.

chaos
I do have that in fact. is there a better way without impacting my production.
Brian G
Well, you could move your newly created entries before it, if you don't want to get rid of it, I guess. But as long as it's there, it's going to keep doing this to new users. If you're worried about getting rid of it, you should probably dig around the MySQL docs for why it's there, which I'm sure there's some weird reason for but I can't recall right now.
chaos
Any more information on this. I am almost positive this is my issue. but I cannot find any more information on it.
Brian G
http://dev.mysql.com/doc/refman/5.1/en/default-privileges.html has something about the 'anonymous accounts' that this empty-username accounts are apparently meant to be. Nothing there seems to be indicating that there's any downside to removing them.
chaos
+1  A: 

You forgot the quotes around brian in your grant statement. Try it like this:

GRANT ALL PRIVILEGES ON *.* to 'brian'@'%' identified by 'password';

Asaph
I see you've now updated the question to add the quotes.
Asaph