1-- Grants list
2SELECT * FROM information_schema.user_privileges;
3SELECT CONCAT('SHOW GRANTS FOR ''',user,'''@''',host,''';') FROM mysql.user;
4
5-- Grant a user
6/* ALL PRIVILEGES All privileges
7 CREATE Create databases and tables
8 DROP Drop databases and tables
9 DELETE Delete rows from a specific table
10 INSERT Insert rows into a specific table
11 SELECT Read a database
12 UPDATE Update table rows */
13GRANT SELECT, UPDATE ON db_name.table_name TO 'my_user'@'localhost';
14GRANT SELECT ON *.* TO 'my_user'@'localhost';
15GRANT ALL PRIVILEGES ON db_name.* TO 'my_user'@'localhost';
16
17--Display user grants
18SHOW GRANTS FOR 'my_user'@'localhost';