Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there any commands to look up databases that has no any activity in a month or so?

Just take SQL dumps for a month and run diff and if there's no differences delete that DB?

share|improve this question
up vote 4 down vote accepted

It depends on what you mean by activity? You wouldn't see updates to a database or changes to the backup for a database that has been designed to store read-only data. But is is possible that database is access frequently.

You could enable the mysql query log and see everything that is accessed, but that will come at the cost of performance.

You could probably do something Mysql Proxy. You could set it up with a bit of work to log all databases that have been accessed. This might have less of a performance impact then enabling logging of everything.

Just looking at the file dates of *.myd files would work for myisam databases provided that active meant that someone was writing too them.

share|improve this answer

Diffing SQL dumps will only show you if a database has been modified, not if it's been queried.

You could potentially use the slow query log to see what queries are being run against the database, although I can't be certain right now if they include the database the query was run against.

If you don't care about reads, you could use the MySQL replication logs to see if there's been any write activity against those databases.

share|improve this answer

A very handy query to show the last update time of a DB:


Thanks to

share|improve this answer
Innodb doesn't write a value to the last_update field so this solution only works for myisam. – Wolfe Oct 9 '14 at 4:02

Dumps wouldn't show no activity, they'd show lack of updates which is NOT the same thing.

I do not know if mysql continually touches the databases that it has open or not. If it doesn't, mtime should tell you. If it does, you'll probably have to look at the logs.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.