MySQL grant privileges has no effect

MySQLpermissions

I've executed the following queries:

GRANT USAGE ON my_db.* TO my_user@127.0.0.1 IDENTIFIED BY 'pass';
GRANT ALL ON my_db.* TO my_user@127.0.0.1;
GRANT SELECT, INSERT, UPDATE, DELETE ON my_db.* TO my_user@127.0.0.1;
FLUSH PRIVILEGES;

But they don't show up.

SHOW GRANTS FOR my_user@127.0.0.1;

results in

GRANT USAGE ON my_db.* TO my_user@127.0.0.1 IDENTIFIED BY '*123...';
GRANT ALL PRIVILEGES ON my_db.* TO my_user@127.0.0.1;

Best Answer

Aley,

GRANT ALL ON my_db.* TO my_user@127.0.0.1;

is a superset of:

GRANT SELECT, INSERT, UPDATE, DELETE ON my_db.* TO my_user@127.0.0.1;

So the last one is superfluous. You must understand that SHOW GRANTS do not show every grant query that you executed, and that in some specific cases, it may not show all grants for a user. That is something that can be very confusing in MySQL.

Also, another tip is that you do not need FLUSH PRIVILEGES; if you only use GRANT/CREATE/DROP keywords, only if you modify directly the mysql.* tables.