How to check the size of a MySQL database
Codemia Knowledge Hub ·
Query information_schema.TABLES and add up data_length + index_length for the schema. That gives the database size in bytes, which you can divide down to megabytes. You can also read sizes in MySQL Workbench or check the data directory on disk.
Using an SQL query
Run this from the MySQL command line, MySQL Workbench or any other client:
Replace 'your_database_name' with your database name. The query sums the data and index lengths stored in information_schema.TABLES and converts bytes to megabytes.
A database's total size includes all its tables and indexes. For a per-table or per-index breakdown, modify the query to return size information for each table or index.
Using MySQL Workbench
- Open MySQL Workbench and connect to your database server.
- Navigate to the "Management" section and select "Server Status."
- Scroll to the "Storage" section where you will see the total size of each database listed.
Checking the file system
If you have direct access to the server, check the database directories in the MySQL data directory. Each database is typically stored in its own directory there (/var/lib/mysql/ on Linux).
This shows each database directory's size in human-readable form (for example MB or GB).
Running these queries or commands frequently, or on large databases, can affect performance. Consider running them during off-peak hours if needed.
Which method to use
| Method | Tool/Approach | Complexity | Best Use Case |
| SQL Query | Command Line/SQL Interface | Low | When you need quick programmatic access. |
| MySQL Workbench | GUI | Low | For users who prefer a graphical interface. |
| File System Check | Server Access / Command Line | Medium | When having direct access to the server. |
Related reading
- How can I get the sizes of the tables of a MySQL database?
- How can I get the SQL of a PreparedStatement?
- How can I get the total number of items in a DynamoDB table?
- How can I implement two sort keys in Dynamo DB?
- How can I implement versioning without replacing with previous record in DynamoDB?
- How can I import a database with MySQL from terminal?
- How can I import a jsonb column from a csv file using the COPY command?
- How can I import a large 14 GB MySQL dump file into a new MySQL database?
System design interview problems on this topic
- Design a Distributed OLTP Database: solution and walkthrough
- Design a Wide Column Database: solution and walkthrough
- Design a Key Value Store: solution and walkthrough
- Design a Web Cache: solution and walkthrough

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseSystem Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.