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

  1. How to Check Database Size in MySQL Picture 1How to Check Database Size in MySQL Picture 1
    Open MySQL Workbench. It has a blue icon that with an image that resembles a dolphin. Click the icon to launch MySQL Workbench.
  2. How to Check Database Size in MySQL Picture 2How to Check Database Size in MySQL Picture 2
    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]
    1. If SQL server is not listed on this screen, click New Connection and enter the server information, including hostname, port, username, and password.
  3. How to Check Database Size in MySQL Picture 3How to Check Database Size in MySQL Picture 3
    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.
  4. How to Check Database Size in MySQL Picture 4How to Check Database Size in MySQL Picture 4
    Click the information icon. It's the icon that resembles an "i" next to the database name in the schema pane.
  5. How to Check Database Size in MySQL Picture 5How to Check Database Size in MySQL Picture 5
    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

  1. How to Check Database Size in MySQL Picture 6How to Check Database Size in MySQL Picture 6
    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.
  2. How to Check Database Size in MySQL Picture 7How to Check Database Size in MySQL Picture 7
    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.
  3. How to Check Database Size in MySQL Picture 8How to Check Database Size in MySQL Picture 8
    Type SUM(data length + table length) 'Size in bytes', as the second line. This command will display the size of each table in bytes.
  4. How to Check Database Size in MySQL Picture 9How to Check Database Size in MySQL Picture 9
    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.
    1. To display a rounded number in kilobytes, type ROUND(SUM(data_length + index_length) / 1024, 2) 'Size in KiB' instead.[3]
  5. How to Check Database Size in MySQL Picture 10How to Check Database Size in MySQL Picture 10
    Type FROM information_schema.tables as the last line. This command specifies which database tables to query.
  6. How to Check Database Size in MySQL Picture 11How to Check Database Size in MySQL Picture 11
    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; 
5 ★ | 1 Vote