Finding Data base size in Mysql



-- Tables Size 
SELECT table_schema,TABLE_NAME, table_type,TABLE_ROWS,data_length,index_length, ROUND((data_length + index_length) / 1024 / 1024, 2)  Size_in_MB,
  NOW() FROM `information_schema`.`tables`  WHERE `table_schema` not in (
'information_schema',
'mysql',
'performance_schema',
'sys');


-- Database size

SELECT table_schema, ROUND(SUM(data_length + index_length) / 1024 / 1024, 2)  Size_in_MB,
  NOW() FROM `information_schema`.`tables`  WHERE `table_schema` not in (
'information_schema',
'mysql',
'performance_schema',

'sys') and TABLE_TYPE='BAse table' group by table_schema;

Comments

Popular Posts