MySQL '%' hostname wildcard I've used the following to grant all privileges on mydb to myusername:

GRANT ALL PRIVILEGES ON mydb.* to myusername @'%' IDENTIFIED BY 'mypassword';


I thought that the % is a wildcard for all hosts. It worked for a while, but then I had some permission errors when the user tried to access the db from the same machine. I added the following lines:

GRANT ALL PRIVILEGES ON mydb.* to myusername @'localhost' IDENTIFIED BY 'mypassword';
GRANT ALL PRIVILEGES ON mydb.* to myusername @'127.0.0.1' IDENTIFIED BY 'mypassword';


And now the user can access the database.

What does the % stand for? Is there a wildcard for all hosts?
Looking up the documentation, two things to mention:


not sure whether a space is allowed before @ (not declared explicitly, but the user string takes the user_name@host_name form - and since this is a string, one can expect that the space is not allowed)
and, better, if you want to grant privileges to a user on all hosts, you can simply omit the @hostname part completely.