MySQL Query to count how many databases a user owns?
mysql
Solution
SELECT COUNT(*) FROM information_schema.SCHEMATA;
(run as the user in Question)
SELECT count(*) FROM (
SELECT DISTINCT TABLE_SCHEMA FROM information_schema.SCHEMA_PRIVILEGES WHERE GRANTEE LIKE("'USERNAME'%") GROUP BY TABLE_SCHEMA
) AS baseview;
(Run as root)
Caveat: There is no such thing as an "Owner" for a database in MySQL, the above queries will show information about the databases a user has soem sort of access to.
Problem
Is there a query like pseudo-code: `SELECT databases FROM mysql.databases WHERE owner = 'myUser'` or any query that'd do the job?