Check MySQL Database & Tables Size

Check Single Database Size in MySQL:

SELECT table_schema "Database Name", SUM( data_length + index_length)/1024/1024"Database Size (MB)" FROM information_schema.TABLES where table_schema = 'mydb';

Check ALL Database Size in MySQL:

SELECT table_schema "Database Name", SUM(data_length+index_length)/1024/1024
"Database Size (MB)"  FROM information_schema.TABLES GROUP BY table_schema;

Check Single Table Size in MySQL Database:

SELECT table_name "Table Name", table_rows "Rows Count", round(((data_length + index_length)/1024/1024),2)
"Table Size (MB)" FROM information_schema.TABLES WHERE table_schema = "mydb" AND table_name ="table_one";

Check All Table Size in MySQL Database:

SELECT table_name "Table Name", table_rows "Rows Count", round(((data_length + index_length)/1024/1024),2)
"Table Size (MB)" FROM information_schema.TABLES WHERE table_schema = "mydb";
Advertisements