##统计每个库大小mysql> use information_schema;
Database changed mysql> SELECT TABLE_SCHEMA,SUM(DATA_LENGTH)/1024/1024/1024 as DATA_LENGTH,SUM(INDEX_LENGTH)/1024/1024/1024 as INDEX_LENGTH,SUM(DATA_LENGTH+INDEX_LENGTH)/1024/1024/1024 as SUM_DATA_INDEX FROM information_schema.TABLES WHERE TABLE_SCHEMA!='information_schema' AND TABLE_SCHEMA!='mysql' GROUP BY TABLE_SCHEMA;##统计库里每个表的大小mysql> SELECT TABLE_NAME,DATA_LENGTH,INDEX_LENGTH,SUM(DATA_LENGTH+INDEX_LENGTH) AS TOTAL_SIZE FROM information_schema.TABLES WHERE TABLE_SCHEMA='hcy' GROUP BY TABLE_NAME;
#统计所有数据库的大小mysql> select sum(data_length+index_length)/1024/1024/1024 from information_schema.tables;