How to Check the Size of MySQL Database using SSH

May 6, 2023 / MySQL

In this article, we’ll go through how check the Size of MySQL Database using SSH Command Line.

Follow the steps to check the MySQL database using of SSH:

  1. Log into SSH using “root”.
  2. Enter the following command:
    mysql -u username -p
  3. When the password prompt appears, enter the “password”.
  4. Copy the follow command, to display all the databases and their sizes in MB.#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;
    Note: If you are searching to display the size of a “single Database”, then you need to change the Databasename to your database.select table_schema `Database`, Round(Sum(data_length + index_length) / 1024 / 1024, 1)
    `Size in MB` FROM information_schema.TABLES WHERE table_schema =
    ‘Databasename’;
    Note: If you are looking to display the size of a “single Database with it’s tables”, then changed the Databasename to your database.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;

In this way, you can view the size of  a MySQL database with the help of command line. For more information on MySQL database, visit to our knowledge base section.

If you want to use phpMyAdmin to determine the size of the MySQL database then Read this How to check the size of MySQL database using phpMyAdmin

Spread the love