Useful for finding users who had permission to access databases that have since been deleted…

SELECT mysql.db.*
FROM mysql.db
LEFT JOIN information_schema.SCHEMATA
    ON information_schema.SCHEMATA.SCHEMA_NAME LIKE mysql.db.Db
WHERE information_schema.SCHEMATA.SCHEMA_NAME IS NULL;

This post was imported from Gist.