I thought I’d quickly post up this quick MySQL snippet to help others who are trying to quickly view the size of a MySQL database from the MySQL CLI.
The following query displays the size of all your current MySQL databases on your server in megabytes:-
SELECT table_schema "Data Base Name", sum( data_length + index_length ) / 1024 / 1024 "Data Base Size in MB" FROM information_schema.TABLES GROUP BY table_schema;
Hope this helps at least a few people, I find this extremely useful when accessing a remote server over SSH and wanting to quickly determine the size of the DB without the need for any GUI clients or exporting the database out.