MySQL create user problem, wildcard host users can't login locally

Sureshot324

Diamond Member
Feb 4, 2003
3,370
0
71
This problem only seems to happen in Linux, not Windows. If I create a user in mysql with a wildcard host (or don't specify the host at all, which should do the same thing), they are unable to login locally. I just get an error:
ERROR 1045 (28000): Access denied for user 'myuser'@'localhost' (using password: YES)
I use this command to create the user:
CREATE USER myuser IDENTIFIED BY 'password'
and this command to login to mysql:
mysql -u myuser -p

If I specify localhost like this:
CREATE USER 'myuser'@'localhost' IDENTIFIED BY 'password'

then they are able to login locally fine. Is this normal? If I specify a wildcard host, shouldn't they be able to login from anywhere, including localhost?
 

Ka0t1x

Golden Member
Jan 23, 2004
1,724
0
71
Have you GRANTED privs for this user? If not, I don't think a host will be used, or no access to resources will be given. I don't know about Windows, but for everything in Linux usually will have to do it with a GRANT afterwards, or its done for me via PHPMyAdmin

soo..

Code:
GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'%'
WITH GRANT OPTION;

That's the wildcard host. Please keep in mind this will give that user privs for EVERYTHING on the database.

http://dev.mysql.com/doc/refman/5.1/en/adding-users.html
 
Last edited:

Sureshot324

Diamond Member
Feb 4, 2003
3,370
0
71
I tried that but no luck. I don't think the problem is with privileges, because if the user exists I should be able to at least login to mysql, even with no privileges at all. Like I said, if I create myuser@localhost, everything works fine, but if I create myuser@% (and drop myuser@localhost), I can't even login to mysql locally, and when I try it says access denied for myuser@localhost.

It seems like the wildcard isn't working, or at least localhost isn't accepted for the wildcard. I could just create both myuser@locahost and myuser@% but I don't think I should have to and on Windows I don't.