Determining the size of MySQL databases and tables
Ce contenu n’est pas encore disponible dans votre langue.
This guide explains how to check the size of MySQL databases and tables using either phpMyAdmin or the MySQL command-line tool.
Using phpMyAdmin
Section titled “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
Section titled “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
Section titled “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.TABLESGROUP BY table_schema;This lists each database and its total size in megabytes.
Check table sizes within a specific database
Section titled “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.TABLESWHERE 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
Section titled “More Information”- phpMyAdmin documentation: https://www.phpmyadmin.net
- MySQL command-line client: https://mariadb.com/kb/en/mysql-command-line-client
Cette page vous a-t-elle aidé ?
Merci pour votre retour.