Question :
I am finding the best way to calculate and list sizes of MySQL or MariaDB Databases ?
Answer :
In order to achive this, please do the following.
1. Enter to mysql root console:
# mysql -u root -p
2. Run the following SQL select query to calculate and list the sizes of all available databases in MySQL or MariaDB.
MariaDB [(none)]> SELECT table_schema AS "DB Name", SUM(data_length + index_length) / 1024 / 1024 AS "Size (MB)" FROM information_schema.TABLES GROUP BY table_schema;
Output :
+--------------------+-------------+ | DB Name | Size (MB) | +--------------------+-------------+ | wordpressdb | 36.79408455 | | information_schema | 0.14062500 | | mysql | 0.62723351 | | oscommercedb | 1.42187500 | | performance_schema | 0.00000000 | +--------------------+-------------+ 5 rows in set (0.02 sec) MariaDB [(none)]>
