> ## Content Index
> Fetch the complete content index at: https://www.bagz.fr/llms.txt
> Use this file to discover other available public pages before exploring further.

# Calculate Database/Table size in MySQL
- URL: https://www.bagz.fr/calculate-databasetable-size-in-mysql/
- Published: 2016-08-11T08:48:07.000Z
- Updated: 2016-08-11T08:48:07.000Z
- Author: bgazui
- Tags: Database, #Migrated-1790668826633, #wp, #wp-post, #Import 2026-09-29 08:00

MySQL is an open-source relational database management system (RDBMS) available under the terms of the GNU General Public License, as well as under a variety of proprietary agreements.

Thanks to some few functions, it's possible to retrieve important information about database size and/or table size for a MySQL instance.

### Size for all databases

SELECT table\_schema "Database Name", SUM(data\_length+index\_length)/1024/1024  
"Database Size (MB)" FROM information\_schema.TABLES GROUP BY table\_schema;  
+---------------------+--------------------+  
| Database Name | Database Size (MB) |  
+---------------------+--------------------+  
| db\_1 | 113.51562500 |  
| db\_2 | 172.59375000 |  
| db\_3 | 48.70312500 |  
| db\_4 | 1830.53125000 |  
| db\_5 | 432.89062500 |  
| information\_schema | 0.07812500 |  
| mysql | 1.03164101 |  
| performance\_schema | 0.00000000 |  
+---------------------+--------------------+  
8 rows in set (0.41 sec)  

### Size of tables for a specific database

SELECT table\_name "Table Name", table\_rows "Rows Count", round(((data\_length + index\_length)/1024/1024),2) "Table Size (MB)" FROM information\_schema.TABLES WHERE table\_schema = "db\_4";  
+-------------------------------+------------+-----------------+  
| Table Name | Rows Count | Table Size (MB) |  
+-------------------------------+------------+-----------------+  
| table\_1 | 245 | 0.05 |  
| table\_2 | 1 | 0.03 |  
| table\_3 | 537 | 0.11 |  
| table\_4 | 1 | 0.05 |  
| table\_5 | 57 | 0.05 |  
| table\_6 | 0 | 0.05 |  
| table\_7 | 2 | 0.05 |  
| table\_8 | 584 | 0.13 |  
| table\_9 | 48 | 0.03 |  
| table\_10 | 12972 | 2.16 |  
| table\_11 | 584 | 0.11 |  
 \[ ... \]  
| table\_50 | 0 | 0.05 |  
| table\_51 | 119864 | 16.03 |  
| table\_52 | 146688 | 9.55 |  
| table\_53 | 48 | 0.05 |  
| table\_54 | 852591 | 208.30 |  
| table\_55 | 138786 | 66.64 |  
| table\_56 | 47 | 0.08 |  
| table\_57 | 169 | 0.09 |  
| table\_58 | 0 | 0.03 |  
+-------------------------------+------------+-----------------+  
58 rows in set (0.00 sec)  
For a complete documentation, please refer to the official documentation on their website [https://www.mysql.com](https://www.mysql.com/)