如何获得MySQL数据库的最后访问(和/或写)时间?

时间:2022-09-25 15:48:07

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

如何查找最近一次读取或写入MySQL数据库?

Can you even do that check per table?

你能对每一张表进行检查吗?

3 个解决方案

#1


6  

SELECT UPDATE_TIME
FROM   INFORMATION_SCHEMA.TABLES
WHERE  TABLE_SCHEMA = 'dbname'
AND    TABLE_NAME = 'tabname'

Source: How can I tell when a MySQL table was last updated?

源:我怎么知道MySQL表最后一次更新是什么时候?

#2


3  

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

如果您的数据库打开了bin日志,您可以使用mysqlbinlog获得最后的更新时间。

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

如果您的数据库启用了查询日志记录,您可以通过跟踪查询日志获得最后的查询时间(更新或选择)。

#3


-1  

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

检查命令显示表状态;示例:显示name="table_name_here"的表状态,需要列Update_time中的值

#1


6  

SELECT UPDATE_TIME
FROM   INFORMATION_SCHEMA.TABLES
WHERE  TABLE_SCHEMA = 'dbname'
AND    TABLE_NAME = 'tabname'

Source: How can I tell when a MySQL table was last updated?

源:我怎么知道MySQL表最后一次更新是什么时候?

#2


3  

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

如果您的数据库打开了bin日志,您可以使用mysqlbinlog获得最后的更新时间。

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

如果您的数据库启用了查询日志记录,您可以通过跟踪查询日志获得最后的查询时间(更新或选择)。

#3


-1  

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

检查命令显示表状态;示例:显示name="table_name_here"的表状态,需要列Update_time中的值