Run SQL Query to Determine the Size of MySQL Databases

Post Reply
User avatar
Eli
Senior Expert Member
Reactions: 183
Posts: 5334
Joined: 9 years ago
Location: Tanzania
Has thanked: 75 times
Been thanked: 88 times
Contact:

#1

Running one of these SQL queries will give you the size of all databases in MB:

  1. SELECT table_schema,
  2.         ROUND(SUM(data_length + index_length) / 1024 / 1024, 1) "DB Size in MB"
  3. FROM "DB Name" information_schema.TABLES
  4. GROUP BY table_schema;

  1. SELECT table_schema AS "Database", SUM(data_length + index_length) / 1024 / 1024 AS "Size (MB)" FROM information_schema.TABLES GROUP BY table_schema


Or

  1. SELECT table_schema AS "Database", SUM(data_length + index_length) / 1024 / 1024 / 1024 AS "Size (GB)" FROM information_schema.TABLES GROUP BY table_schema


to get size in GB.


You can however specify the database by replacing DB Name with the actual database if you want to check the size of a specific database.

Ref: DB Queries
0
TSSFL -- A Creative Journey Towards Infinite Possibilities!
User avatar
Eli
Senior Expert Member
Reactions: 183
Posts: 5334
Joined: 9 years ago
Location: Tanzania
Has thanked: 75 times
Been thanked: 88 times
Contact:

#2

Once you know the size, you can then make sure you export the correct size of your database for backup:

To create a backup of your MySQL Database:
  • Log in to cPanel.
  • In the Files section, click on the Backups icon.
  • Under Partial Backups, look for Download a MySQL Database Backup, and then click the name of the specific database you want to backup.
  • Wait for the download to complete.
See more

https://www.hostgator.com/help/article/ ... phpmyadmin
1
1 Image
TSSFL -- A Creative Journey Towards Infinite Possibilities!
Post Reply

Return to “Web Servers & Databases”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 9 guests