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

  1. Log in to cPanel.

  2. In the Databases section, click phpMyAdmin.

  3. When phpMyAdmin opens, select the database you want from the left pane.

  4. In the right pane, locate the Size column. This shows the size of each table.

  5. 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

  1. Log in to your account using SSH.

  2. At the command prompt, enter the following (replace username with your actual username):

mysql -u username -p
  1. 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

Hjälpte svaret dig? 0 användare blev hjälpta av detta svar (0 Antal röster)

Powered by WHMCompleteSolution