MySQL – Grant Select on All Databases Except One

MySQLmysql-5.5permissions

I have user called test_user created under MySQL 5.5.17 under MS Windows 2008R2, I want to grant this user select privileges on all databases except MySQL database, note I have around 200 database inside this instance.

EDIT:

enter image description here

EDIT2:

enter image description here

Best Answer

Run the output of the following query:

SELECT CONCAT("GRANT SELECT ON ",SCHEMA_NAME,".* TO 'test_user'@'localhost';")
FROM information_schema.SCHEMATA 
WHERE SCHEMA_NAME NOT LIKE 'mysql';