How to Check Database Size in MySQL
This wikiHow teaches you how to check the size of a MySQL database. You can check the size of a database using MySQL Workbench, or by running a query in MySQL. Open MySQL Workbench. It has a blue icon that with an image that resembles a...
Method 1 of 2:
Using MySQL Workbench
- Open MySQL Workbench. It has a blue icon that with an image that resembles a dolphin. Click the icon to launch MySQL Workbench.
- Connect to the MySQL server. Double-click the MySQL server on under the SQL Development module in the start-up screen. Then enter the database password to connect. [1]
- If SQL server is not listed on this screen, click New Connection and enter the server information, including hostname, port, username, and password.
- Hover over the database in the schema pane. It's in the sidebar to the left. This displays a couple of icons to the right of the database name.
- Click the information icon. It's the icon that resembles an "i" next to the database name in the schema pane.
- Click the Info tab. It's the first tab in the main pane in the center. This displays information about the database. The database size is listed next to "Database size (rough estimate). this displays a rough estimate of the size of the database. [2]
Method 2 of 2:
Running a Query
- Connect to a MySQL server. There are a number of apps you can use to connect to a MySQL database, including MySQL Workbench. You can also query a MySQL database in the command line in Windows, or terminal on Mac. Once MySQL is installed on your computer you'll need to navigate to the MySQL directory in the Windows command line and type mysql -u root -p. Then enter the password for your database.
- Type SELECT table_schema "DB Name", as the first line of your query. This is the select command to query run a query on the database.
- Type SUM(data length + table length) 'Size in bytes', as the second line. This command will display the size of each table in bytes.
- Type ROUND(SUM(data_length + index_length) / 1024 / 1024, 2) 'Size in MiB' as the next line. This displays a rounded number of the size in megabytes.
- To display a rounded number in kilobytes, type ROUND(SUM(data_length + index_length) / 1024, 2) 'Size in KiB' instead.[3]
- Type FROM information_schema.tables as the last line. This command specifies which database tables to query.
- Type GROUP BY table_schema; and execute the query. This will display the size of your databases. You can also type {[kbd|WHERE table_schema = 'database name';}} to check the size of a specific database. Type the actual name of the database in place of "database name". Your query should look something like this:
SELECT table_schema "DB Name" SUM(data length + table length) 'Size in bytes', ROUND(SUM(data_length + index_length) / 1024 / 1024, 2) 'Size in MiB' FROM information_schema.tables GROUP BY table_schema;
Update 05 March 2020
You should read it
- How to create a database in MySQL
- Instructions for installing MySQL on Windows and remote access
- Instructions on how to connect to MySQL Database in Eclipse
- Backup and restore MySQL with mysql-zrm on Debian Sarge
- A serious vulnerability on phpMyAdmin allows an attacker to destroy the database
- How to Connect to MySQL Using PHP
- Save your database with Recovery Toolbox for MySQL
- How to install MySQL on Ubuntu 20.04
- How to install and configure MySQL server on Pi
- How to Create a Secure Session Management System in PHP and MySQL
- Best tools for designing and administering Mysql databases
- How to Learn PHP and MySQL