How do I get the size of the database in mysql

  • 2020-05-24 06:21:03
  • OfStack

1. View the mysql database size
SELECT sum(DATA_LENGTH)+sum(INDEX_LENGTH)
FROM information_schema. TABLES where TABLE_SCHEMA=' database name ';
The result is in bytes, K divided by 1024 and M divided by 1048576(=1024*1024).

2. View the last time mysql was modified in the table
select TABLE_NAME,UPDATE_TIME INFORMATION_SCHEMA. tables where TABLE_SCHEMA=' database name ';
You can determine if the mysql database is no longer in use by looking at when the mysql tables in the database were modified.


Related articles: