Monday, 12 March 2018

How to get the database size of the MySQL DB ?



mysql -e "SELECT table_schema AS 'Database Name', SUM((data_length+index_length)/1024/1024) AS 'Database Size in MB
FROM information_schema.TABLES where table_schema='dbname';"

EXAMPLE
mysql -e "SELECT table_schema AS 'Database Name', SUM((data_length+index_length)/1024/1024) AS 'Database Size in MB
FROM information_schema.TABLES where table_schema='employee';"


ANSWER


+---------------+---------------------+
| Database Name | Database Size in MB |
+---------------+---------------------+
| employee      |       7224.01562500 |
+---------------+---------------------+

No comments:

Post a Comment

Note: only a member of this blog may post a comment.