mysql_database_sizes
This is an old revision of the document!
Warning: Undefined variable $state in /usr/share/nginx/html/lib/plugins/tabinclude/helper.php on line 130
Warning: Undefined variable $html in /usr/share/nginx/html/lib/plugins/tabinclude/helper.php on line 240
−Table of Contents
Apache vhost
- Size of ALL databases
- Size of a tables in a db
1 |
# mysql --silent --table |
[mysql] silent table
Size of ALL databases
Note: You do not need to change the 'Database Name' entry
1 2 3 4 5 6 7 8 9 |
SELECT table_schema "Database Name" , sum ( data_length + index_length ) / 1024 / 1024 "Database Size in MB" , sum ( data_free )/ 1024 / 1024 "Free Space in MB" FROM information_schema.TABLES GROUP BY table_schema ; |
File size of a specific db
The following commands should be run inside mysql
Note: replace “Data Base Name” with the db name.
1 2 3 4 5 6 7 8 9 |
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 WHERE table_schema = "$DATABASE_NAME" ; |
Size of ALL databases
Note: You do not need to change the 'Database Name' entry
1 2 3 4 5 6 7 8 9 |
SELECT table_schema "Database 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 ; |
File size of a specific db
The following commands should be run inside mysql
Note: replace “Data Base Name” with the db name.
1 2 3 4 5 6 7 8 9 |
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 WHERE table_schema = "$DATABASE_NAME" |
Size of a table in a db
Note: You will need to replace DATABASE_NAME and TABLE_NAME.
1 2 3 4 5 6 7 8 9 |
SELECT table_name AS "Table" , round(((data_length + index_length) / 1024 / 1024), 2) "Size in MB" FROM information_schema.TABLES WHERE table_schema = "$DATABASE_NAME" AND table_name = "$TABLE_NAME" ; |
mysql_database_sizes.1487839668.txt.gz · Last modified: 2024/05/23 07:26 (external edit)