Determining the Size of MySQL Databases and Tables
This guide explains how to check the size of MySQL databases and tables using either phpMyAdmin or the MySQL command-line tool.
Using phpMyAdmin
-
Log in to cPanel.
-
In the Databases section, click phpMyAdmin.
-
When phpMyAdmin opens, select the database you want from the left pane.
-
In the right pane, locate the Size column. This shows the size of each table.
-
To find the total database size, scroll to the bottom of the Size column.
-
If the database has many tables, use the > button to move to the next page and add the totals manually.
-
Using the MySQL Command Line
-
Log in to your account using SSH.
-
At the command prompt, enter the following (replace
usernamewith your actual username):
mysql -u username -p
-
Enter your password when prompted.
Check the size of all databases
SELECT table_schema AS "Database",
ROUND(SUM(data_length + index_length) / 1024 / 1024, 2) AS "Size (MB)"
FROM information_schema.TABLES
GROUP BY table_schema;
This lists each database and its total size in megabytes.
Check table sizes within a specific database
Replace database_name with the name of the database you want to check:
SELECT table_name AS "Table",
ROUND((data_length + index_length) / 1024 / 1024, 2) AS "Size (MB)"
FROM information_schema.TABLES
WHERE table_schema = "database_name"
ORDER BY (data_length + index_length) DESC;
This shows each table and its size in megabytes, sorted from largest to smallest.
More Information
-
phpMyAdmin documentation: https://www.phpmyadmin.net
-
MySQL command-line client: https://mariadb.com/kb/en/mysql-command-line-client