Get MySQL Database/Tables Size (in MB)

## query list of tables and sizes in specific database SELECT table_name, round(((data_length + index_length) / 1024 / 1024), 0) as sizeInMb FROM information_schema.TABLES where table_schema = 'db_name'; ## query specific table size by database name and table name: SELECT table_name, round(((data_length + index_length) / 1024 / 1024), 0) as sizeInMb FROM information_schema.TABLES where table_schema = 'db_name' and table_name = 'table_name'; ## query databases, db size and free space SELECT table_schema "Data Base Name", sum( data_length + index_length ) / 1024 / 1024 "Data Base Size in MB", sum( data_free )/ 1024 / 1024 "Free Space in MB" FROM information_schema.TABLES GROUP BY table_schema ;
Some query statements to get MySql database and table sizes (in MB)

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.