views:

94

answers:

3

How do you find out the last time a MySQL database was read or written to?

Can you even do that check per table?

+2  A: 

SELECT UPDATE_TIME FROM information_schema.tables WHERE TABLE_SCHEME = 'dbname' AND TABLE_NAME = 'tabname'

From here: http://stackoverflow.com/questions/307438/how-can-i-tell-when-a-mysql-table-was-last-updated

lecodesportif
This only works for MyISAM, not InnoDB.
Ike Walker
It's table_schema, not table_scheme.
Neil
A: 

check out command SHOW TABLE STATUS;
example: SHOW TABLE STATUS WHERE name="table_name_here", you need value from column Update_time

antony
Again, this only works for MyISAM, not InnoDB.
Ike Walker
+1  A: 

If your database has bin logs switched on, you can get the last update time using mysqlbinlog.

If your database has query logging enabled, you can get the last query time (either updates or selects) by tailing the query log.

Martin