Answer the question
In order to leave comments, you need to log in
How to delete MYSQL databases that are more than 30 days old?
There is a mysql server5.6 on it, databases for tests are often created, but the creator does not always delete the database, so it is necessary to delete all databases that are older than 30 days. How to at least list all databases that are older than 30 days, based on the date of the oldest table in the potential database.
Answer the question
In order to leave comments, you need to log in
list of oldest tables from all databases
SELECT TABLE_SCHEMA, TABLE_NAME, MAX(CREATE_TIME) created FROM information_schema.tables
GROUP BY TABLE_SCHEMA
ORDER BY created
SELECT TABLE_SCHEMA, TABLE_NAME, MAX(CREATE_TIME) created FROM information_schema.tables
GROUP BY TABLE_SCHEMA
HAVING created < (NOW() - INTERVAL 1 MONTH)
ORDER BY created
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question