Jump to: navigation, search

MySQL Get Database size

From w3cyberlearnings

How to list all the database using command line

The default location where MySQL database stored in Linux OS.

root@sophal-desktop:/# ls /var/lib/mysql

How to check the mysql database size using command line

root@sophal-desktop:/# du -sk /var/lib/mysql/book
452	/var/lib/mysql/book

how to get the mysql database size using SELECT statement on the INFORMATION_SCHEMA database


mysql> SELECT TABLE_SCHEMA AS 'Database', TABLE_NAME AS 'Table', 
    -> CONCAT(ROUND(((DATA_LENGTH + INDEX_LENGTH - DATA_FREE) / 1024 / 1024),2)," MB") 
    -> AS Size FROM INFORMATION_SCHEMA.TABLES where TABLE_SCHEMA='phpbb3';
+----------+----------------------------+---------+
| Database | Table                      | Size    |
+----------+----------------------------+---------+
| phpbb3   | phpbb_acl_groups           | 0.00 MB | 
| phpbb3   | phpbb_acl_options          | 0.01 MB | 
| phpbb3   | phpbb_acl_roles            | 0.01 MB | 
| phpbb3   | phpbb_acl_roles_data       | 0.02 MB | 
| phpbb3   | phpbb_acl_users            | 0.00 MB | 
| phpbb3   | phpbb_attachments          | 0.00 MB | 
.............
Navigation
Web
SQL
MISC
References