{"id":26277,"date":"2022-09-30T09:02:33","date_gmt":"2022-09-30T02:02:33","guid":{"rendered":"https:\/\/tom.ji42.com\/?p=26277"},"modified":"2022-09-30T09:02:33","modified_gmt":"2022-09-30T02:02:33","slug":"how-to-check-mysql-database-and-table-size","status":"publish","type":"post","link":"https:\/\/tom.tomwork.net\/?p=26277","title":{"rendered":"How to Check MySQL Database and Table Size"},"content":{"rendered":"<h2 id=\"ftoc-heading-1\" class=\"ftwp-heading\">How to Check MySQL Database and Table Size<\/h2>\n<p>There are three ways to check MySQL database and table sizes:<\/p>\n<p>1. Using\u00a0<strong>phpMyAdmin<\/strong>.<\/p>\n<p>2. Using the\u00a0<strong>SELECT<\/strong>\u00a0statement.<\/p>\n<p>3. Using\u00a0<strong>MySQL workbench<\/strong>.<\/p>\n<p>All methods provide ways to check the size for:<\/p>\n<ul>\n<li>A single database.<\/li>\n<li>All databases.<\/li>\n<li>Table size for a single database.<\/li>\n<li>Table size for all databases.<\/li>\n<\/ul>\n<p>Choose a method that best fits your configuration and follow the step-by-step instructions below.<!--more--><\/p>\n<h3 id=\"ftoc-heading-2\" class=\"ftwp-heading\">Method 1: Using phpMyAdmin<\/h3>\n<p>Use the phpMyAdmin web interface to access information about MySQL databases and tables, including their sizes. Start by logging into your phpMyAdmin administration page.<\/p>\n<p><strong>Get the Size for a Single Database<\/strong><\/p>\n<p>Follow these steps to check the size for a single database using phpMyAdmin:<\/p>\n<p>1. Select the database name on the left pane.<\/p>\n<p>2. Locate the\u00a0<strong>Size<\/strong>\u00a0column. The individual table sizes display in the output.<\/p>\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-138304 entered lazyloaded\" src=\"https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/phpmyadmin-database-size.png\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" srcset=\"https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/phpmyadmin-database-size.png 800w, https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/phpmyadmin-database-size-300x113.png 300w, https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/phpmyadmin-database-size-768x288.png 768w\" alt=\"Database size in phpMyAdmin\" width=\"800\" height=\"300\" data-lazy-srcset=\"https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/phpmyadmin-database-size.png 800w, https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/phpmyadmin-database-size-300x113.png 300w, https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/phpmyadmin-database-size-768x288.png 768w\" data-lazy-sizes=\"(max-width: 800px) 100vw, 800px\" data-lazy-src=\"https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/phpmyadmin-database-size.png\" data-ll-status=\"loaded\" \/><\/figure>\n<p>Scroll to the bottom to see the total size for the selected database, which is the total sum.<\/p>\n<p><strong>Get the Size for all Databases<\/strong><\/p>\n<p>To find the size of all databases in phpMyAdmin:<\/p>\n<p>1. On the\u00a0<em>index\u00a0<\/em>page, locate and select the\u00a0<strong>Databases<\/strong>\u00a0tab in the top navbar.<\/p>\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-138305 entered lazyloaded\" src=\"https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/phpmyadmin-databases-tab.png\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" srcset=\"https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/phpmyadmin-databases-tab.png 800w, https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/phpmyadmin-databases-tab-300x86.png 300w, https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/phpmyadmin-databases-tab-768x221.png 768w\" alt=\"Databases tab in phpMyAdmin\" width=\"800\" height=\"230\" data-lazy-srcset=\"https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/phpmyadmin-databases-tab.png 800w, https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/phpmyadmin-databases-tab-300x86.png 300w, https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/phpmyadmin-databases-tab-768x221.png 768w\" data-lazy-sizes=\"(max-width: 800px) 100vw, 800px\" data-lazy-src=\"https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/phpmyadmin-databases-tab.png\" data-ll-status=\"loaded\" \/><\/figure>\n<p>2. Below the table, select\u00a0<strong>Enable statistics<\/strong>.<\/p>\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-138307 entered lazyloaded\" src=\"https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/phpmyadmin-enable-database-statistics.png\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" srcset=\"https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/phpmyadmin-enable-database-statistics.png 800w, https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/phpmyadmin-enable-database-statistics-300x135.png 300w, https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/phpmyadmin-enable-database-statistics-768x346.png 768w\" alt=\"Enable statistics in phpMyAdmin\" width=\"800\" height=\"360\" data-lazy-srcset=\"https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/phpmyadmin-enable-database-statistics.png 800w, https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/phpmyadmin-enable-database-statistics-300x135.png 300w, https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/phpmyadmin-enable-database-statistics-768x346.png 768w\" data-lazy-sizes=\"(max-width: 800px) 100vw, 800px\" data-lazy-src=\"https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/phpmyadmin-enable-database-statistics.png\" data-ll-status=\"loaded\" \/><\/figure>\n<p>Enabling statistics can cause high traffic between MySQL and\u00a0<a href=\"https:\/\/phoenixnap.com\/blog\/web-server-vs-application-server\" target=\"_blank\" rel=\"noreferrer noopener\">web servers<\/a>. Use this method when there&#8217;s low traffic to minimize server overload.<\/p>\n<p>3. The\u00a0<em>Database statistics<\/em>\u00a0page displays general statistics about all the databases, including the size. The column\u00a0<em>Total\u00a0<\/em>sums the\u00a0<strong>Data<\/strong>\u00a0and\u00a0<strong>Indexes<\/strong>\u00a0columns.<\/p>\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-138308 entered lazyloaded\" src=\"https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/phpmyadmin-database-statistics-total-size.png\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" srcset=\"https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/phpmyadmin-database-statistics-total-size.png 800w, https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/phpmyadmin-database-statistics-total-size-300x135.png 300w, https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/phpmyadmin-database-statistics-total-size-768x346.png 768w\" alt=\"Database statistics total size phpMyAdmin\" width=\"800\" height=\"360\" data-lazy-srcset=\"https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/phpmyadmin-database-statistics-total-size.png 800w, https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/phpmyadmin-database-statistics-total-size-300x135.png 300w, https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/phpmyadmin-database-statistics-total-size-768x346.png 768w\" data-lazy-sizes=\"(max-width: 800px) 100vw, 800px\" data-lazy-src=\"https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/phpmyadmin-database-statistics-total-size.png\" data-ll-status=\"loaded\" \/><\/figure>\n<p>The last row shows the sizes summed up.<\/p>\n<p><strong>Get Table Size for a Single Database<\/strong><\/p>\n<p>To check the size for a single database table:<\/p>\n<p>1. Click a database name in the left pane to select a database.<\/p>\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-138309 entered lazyloaded\" src=\"https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/phpmyadmin-databases-list-left-pane.png\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" srcset=\"https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/phpmyadmin-databases-list-left-pane.png 800w, https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/phpmyadmin-databases-list-left-pane-300x98.png 300w, https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/phpmyadmin-databases-list-left-pane-768x250.png 768w\" alt=\"Databases list left pane phpMyAdmin\" width=\"800\" height=\"260\" data-lazy-srcset=\"https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/phpmyadmin-databases-list-left-pane.png 800w, https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/phpmyadmin-databases-list-left-pane-300x98.png 300w, https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/phpmyadmin-databases-list-left-pane-768x250.png 768w\" data-lazy-sizes=\"(max-width: 800px) 100vw, 800px\" data-lazy-src=\"https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/phpmyadmin-databases-list-left-pane.png\" data-ll-status=\"loaded\" \/><\/figure>\n<p>2. Use the search bar to filter tables by name.<\/p>\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-138310 entered lazyloaded\" src=\"https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/phpmyadmin-search-bar.png\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" srcset=\"https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/phpmyadmin-search-bar.png 800w, https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/phpmyadmin-search-bar-300x71.png 300w, https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/phpmyadmin-search-bar-768x182.png 768w\" alt=\"Search bar phpMyAdmin\" width=\"800\" height=\"190\" data-lazy-srcset=\"https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/phpmyadmin-search-bar.png 800w, https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/phpmyadmin-search-bar-300x71.png 300w, https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/phpmyadmin-search-bar-768x182.png 768w\" data-lazy-sizes=\"(max-width: 800px) 100vw, 800px\" data-lazy-src=\"https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/phpmyadmin-search-bar.png\" data-ll-status=\"loaded\" \/><\/figure>\n<p>Alternatively, locate the table manually in the list below the search bar.<\/p>\n<p>3. Find the\u00a0<strong>Size<\/strong>\u00a0column and check the table size.<\/p>\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-138311 entered lazyloaded\" src=\"https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/phpmyadmin-table-size.png\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" srcset=\"https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/phpmyadmin-table-size.png 800w, https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/phpmyadmin-table-size-300x45.png 300w, https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/phpmyadmin-table-size-768x115.png 768w\" alt=\"Table size phpMyAdmin\" width=\"800\" height=\"120\" data-lazy-srcset=\"https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/phpmyadmin-table-size.png 800w, https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/phpmyadmin-table-size-300x45.png 300w, https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/phpmyadmin-table-size-768x115.png 768w\" data-lazy-sizes=\"(max-width: 800px) 100vw, 800px\" data-lazy-src=\"https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/phpmyadmin-table-size.png\" data-ll-status=\"loaded\" \/><\/figure>\n<p>If not immediately visible, scroll the table to the right until the column is visible.<\/p>\n<p><strong>Get Table Size for All Databases<\/strong><\/p>\n<p>Check all database table sizes in phpMyAdmin using the\u00a0<strong><code>SELECT<\/code><\/strong>\u00a0query.<\/p>\n<p>1. On the\u00a0<em>index<\/em>\u00a0page, select the\u00a0<strong>SQL<\/strong>\u00a0tab.<\/p>\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-138312 entered lazyloaded\" src=\"https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/phpmyadmin-sql-tab.png\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" srcset=\"https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/phpmyadmin-sql-tab.png 800w, https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/phpmyadmin-sql-tab-300x68.png 300w, https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/phpmyadmin-sql-tab-768x173.png 768w\" alt=\"SQL tab in phpMyAdmin\" width=\"800\" height=\"180\" data-lazy-srcset=\"https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/phpmyadmin-sql-tab.png 800w, https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/phpmyadmin-sql-tab-300x68.png 300w, https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/phpmyadmin-sql-tab-768x173.png 768w\" data-lazy-sizes=\"(max-width: 800px) 100vw, 800px\" data-lazy-src=\"https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/phpmyadmin-sql-tab.png\" data-ll-status=\"loaded\" \/><\/figure>\n<p>2. Enter the following query to display the table size for all databases:<\/p>\n<pre class=\"wp-block-code copy-the-code-target\"><code>SELECT TABLE_SCHEMA AS `Database`,\r\nTABLE_NAME AS `Table`,\r\nROUND((DATA_LENGTH + INDEX_LENGTH) \/ 1024 \/ 1024) AS `Size (MB)`\r\nFROM information_schema.TABLES\r\nORDER BY (DATA_LENGTH + INDEX_LENGTH) DESC;\r\n<\/code><button class=\"copy-the-code-button\" title=\"Copy to Clipboard\" data-style=\"svg-icon\"><\/button><\/pre>\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-138313 entered lazyloaded\" src=\"https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/phpmyadmin-all-table-size-query.png\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" srcset=\"https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/phpmyadmin-all-table-size-query.png 800w, https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/phpmyadmin-all-table-size-query-300x120.png 300w, https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/phpmyadmin-all-table-size-query-768x307.png 768w\" alt=\"All table sizes query in phpMyAdmin\" width=\"800\" height=\"320\" data-lazy-srcset=\"https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/phpmyadmin-all-table-size-query.png 800w, https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/phpmyadmin-all-table-size-query-300x120.png 300w, https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/phpmyadmin-all-table-size-query-768x307.png 768w\" data-lazy-sizes=\"(max-width: 800px) 100vw, 800px\" data-lazy-src=\"https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/phpmyadmin-all-table-size-query.png\" data-ll-status=\"loaded\" \/><\/figure>\n<p>Divide twice by 1024 to get the size in MB and once in KB. Press\u00a0<strong>Go<\/strong>\u00a0to run the query and fetch the result.<\/p>\n<p>3. The output shows the table sizes for all databases in the last column.<\/p>\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-138314 entered lazyloaded\" src=\"https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/phpmyadmin-all-table-size-query-output.png\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" srcset=\"https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/phpmyadmin-all-table-size-query-output.png 800w, https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/phpmyadmin-all-table-size-query-output-300x113.png 300w, https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/phpmyadmin-all-table-size-query-output-768x288.png 768w\" alt=\"Output of all table size query in phpMyAdmin\" width=\"800\" height=\"300\" data-lazy-srcset=\"https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/phpmyadmin-all-table-size-query-output.png 800w, https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/phpmyadmin-all-table-size-query-output-300x113.png 300w, https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/phpmyadmin-all-table-size-query-output-768x288.png 768w\" data-lazy-sizes=\"(max-width: 800px) 100vw, 800px\" data-lazy-src=\"https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/phpmyadmin-all-table-size-query-output.png\" data-ll-status=\"loaded\" \/><\/figure>\n<p>4. Drag and drop the columns to manage the order, or click on the column name to sort the output.<\/p>\n<h3 id=\"ftoc-heading-3\" class=\"ftwp-heading\">Method 2: Using the SELECT MySQL Command-Line Statement<\/h3>\n<p>The database and tables sizes are available through the MySQL command-line interface.<\/p>\n<p>1. Open the terminal (<strong>CTRL<\/strong>+<strong>ALT<\/strong>+<strong>T<\/strong>) and start the MySQL monitor with:<\/p>\n<pre class=\"wp-block-code copy-the-code-target\"><code>mysql -u &lt;username&gt; -p<\/code><button class=\"copy-the-code-button\" title=\"Copy to Clipboard\" data-style=\"svg-icon\"><\/button><\/pre>\n<p>2. Type the password when prompted and press\u00a0<strong>Enter<\/strong>. The terminal shows the\u00a0<strong>mysql&gt;<\/strong>\u00a0prompt.<\/p>\n<div class=\"notice-note\">\n<div class=\"note-icon-wrapper\"><\/div>\n<div class=\"notice-text\">\n<p><strong>Note:\u00a0<\/strong>If you&#8217;re getting an access denied error, follow our troubleshooting guide:\u00a0<a href=\"https:\/\/phoenixnap.com\/kb\/access-denied-for-user-root-localhost\" target=\"_blank\" rel=\"noopener\">Access denied for user\u00a0root@localhost<\/a>.<\/p>\n<\/div>\n<\/div>\n<p>Below are several example queries using the\u00a0<strong><code>SELECT<\/code><\/strong>\u00a0statement. All the outputs show the size in MB with two decimal places.<\/p>\n<p><strong>Get the Size for a Single Database<\/strong><\/p>\n<p>Use the\u00a0<strong><code>SELECT<\/code><\/strong>\u00a0statement to get the size of a single database:<\/p>\n<pre class=\"wp-block-code copy-the-code-target\"><code>SELECT TABLE_SCHEMA AS `Database`, \r\nROUND(SUM(DATA_LENGTH + INDEX_LENGTH) \/ 1024 \/ 1024, 2) AS `Size (MB)` \r\nFROM information_schema.TABLES\r\nWHERE TABLE_SCHEMA=\"&lt;database name&gt;\";\r\n<\/code><button class=\"copy-the-code-button\" title=\"Copy to Clipboard\" data-style=\"svg-icon\"><\/button><\/pre>\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-138316 entered lazyloaded\" src=\"https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/mysql-select-database-size.png\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" srcset=\"https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/mysql-select-database-size.png 800w, https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/mysql-select-database-size-300x90.png 300w, https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/mysql-select-database-size-768x230.png 768w\" alt=\"MySQL select database size query output\" width=\"800\" height=\"240\" data-lazy-srcset=\"https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/mysql-select-database-size.png 800w, https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/mysql-select-database-size-300x90.png 300w, https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/mysql-select-database-size-768x230.png 768w\" data-lazy-sizes=\"(max-width: 800px) 100vw, 800px\" data-lazy-src=\"https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/mysql-select-database-size.png\" data-ll-status=\"loaded\" \/><\/figure>\n<p>Change the\u00a0<strong>&lt;database name&gt;<\/strong>\u00a0to the database you&#8217;d like to check.<\/p>\n<div class=\"notice-note\">\n<div class=\"note-icon-wrapper\"><\/div>\n<div class=\"notice-text\">\n<p><strong>Note:\u00a0<\/strong>Use\u00a0<strong><code>SHOW DATABASES;<\/code><\/strong>\u00a0to\u00a0<a href=\"https:\/\/phoenixnap.com\/kb\/how-to-list-all-databases-mysql\" target=\"_blank\" rel=\"noreferrer noopener\">list all the databases<\/a>\u00a0and find the exact name. For other useful MySQL commands, grab our free\u00a0<a href=\"https:\/\/phoenixnap.com\/kb\/mysql-commands-cheat-sheet\" target=\"_blank\" rel=\"noreferrer noopener\">MySQL cheat sheet<\/a>.<\/p>\n<\/div>\n<\/div>\n<p><strong>Get the Size for all Databases<\/strong><\/p>\n<p>View the size of all databases with the following query:<\/p>\n<pre class=\"wp-block-code copy-the-code-target\"><code>SELECT TABLE_SCHEMA AS `Database`, \r\nROUND(SUM(DATA_LENGTH + INDEX_LENGTH) \/ 1024 \/ 1024, 2) AS `Size (MB)` \r\nFROM information_schema.TABLES\r\nGROUP BY TABLE_SCHEMA \r\nORDER BY SUM(DATA_LENGTH + INDEX_LENGTH) DESC;\r\n<\/code><button class=\"copy-the-code-button\" title=\"Copy to Clipboard\" data-style=\"svg-icon\"><\/button><\/pre>\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-138317 entered lazyloaded\" src=\"https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/mysql-select-all-database-sizes.png\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" srcset=\"https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/mysql-select-all-database-sizes.png 800w, https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/mysql-select-all-database-sizes-300x128.png 300w, https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/mysql-select-all-database-sizes-768x326.png 768w\" alt=\"MySQL select all database sizes query output\" width=\"800\" height=\"340\" data-lazy-srcset=\"https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/mysql-select-all-database-sizes.png 800w, https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/mysql-select-all-database-sizes-300x128.png 300w, https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/mysql-select-all-database-sizes-768x326.png 768w\" data-lazy-sizes=\"(max-width: 800px) 100vw, 800px\" data-lazy-src=\"https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/mysql-select-all-database-sizes.png\" data-ll-status=\"loaded\" \/><\/figure>\n<p>The output shows database sizes sorted in descending order in MB.<\/p>\n<p><strong>Get Table Size for a Single Database<\/strong><\/p>\n<p>List table sizes for a single database by using:<\/p>\n<pre class=\"wp-block-code copy-the-code-target\"><code>SELECT TABLE_NAME AS `Table`,\r\nROUND(((DATA_LENGTH + INDEX_LENGTH) \/ 1024 \/ 1024), 2) AS `Size (MB)` \r\nFROM information_schema.TABLES \r\nWHERE table_schema = \"&lt;database name&gt;\" \r\nORDER BY (data_length + index_length) DESC;\r\n<\/code><button class=\"copy-the-code-button\" title=\"Copy to Clipboard\" data-style=\"svg-icon\"><\/button><\/pre>\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-138318 entered lazyloaded\" src=\"https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/mysql-select-single-database-table-size.png\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" srcset=\"https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/mysql-select-single-database-table-size.png 800w, https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/mysql-select-single-database-table-size-300x86.png 300w, https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/mysql-select-single-database-table-size-768x221.png 768w\" alt=\"MySQL select single database table sizes query output\" width=\"800\" height=\"230\" data-lazy-srcset=\"https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/mysql-select-single-database-table-size.png 800w, https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/mysql-select-single-database-table-size-300x86.png 300w, https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/mysql-select-single-database-table-size-768x221.png 768w\" data-lazy-sizes=\"(max-width: 800px) 100vw, 800px\" data-lazy-src=\"https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/mysql-select-single-database-table-size.png\" data-ll-status=\"loaded\" \/><\/figure>\n<p>Exchange\u00a0<strong><code>&lt;database name&gt;<\/code><\/strong>\u00a0for the actual database name. The output sorts the tables by size in descending order in MB.<\/p>\n<p><strong>Get Table Size for All Databases<\/strong><\/p>\n<p>Show table sizes for all databases with:<\/p>\n<pre class=\"wp-block-code copy-the-code-target\"><code>SELECT TABLE_SCHEMA AS `Database`,\r\nTABLE_NAME AS `Table`,\r\nROUND((DATA_LENGTH + INDEX_LENGTH) \/ 1024 \/ 1024) AS `Size (MB)`\r\nFROM information_schema.TABLES\r\nORDER BY (DATA_LENGTH + INDEX_LENGTH) DESC;\r\n<\/code><button class=\"copy-the-code-button\" title=\"Copy to Clipboard\" data-style=\"svg-icon\"><\/button><\/pre>\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-138319 entered lazyloaded\" src=\"https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/mysql-select-tables-all-databases-size.png\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" srcset=\"https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/mysql-select-tables-all-databases-size.png 800w, https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/mysql-select-tables-all-databases-size-300x139.png 300w, https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/mysql-select-tables-all-databases-size-768x355.png 768w\" alt=\"MySQL select all tables databases size query output\" width=\"800\" height=\"370\" data-lazy-srcset=\"https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/mysql-select-tables-all-databases-size.png 800w, https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/mysql-select-tables-all-databases-size-300x139.png 300w, https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/mysql-select-tables-all-databases-size-768x355.png 768w\" data-lazy-sizes=\"(max-width: 800px) 100vw, 800px\" data-lazy-src=\"https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/mysql-select-tables-all-databases-size.png\" data-ll-status=\"loaded\" \/><\/figure>\n<p>The query sorts the output by database size. Change the last line to sort by a different parameter.<\/p>\n<h3 id=\"ftoc-heading-4\" class=\"ftwp-heading\">Method 3: Using MySQL Workbench<\/h3>\n<p>The\u00a0<strong><code>SELECT<\/code><\/strong>\u00a0query methods work equally well for MySQL Workbench. However, the program provides two additional ways to quickly check the size of a single database and the tables inside a database.<\/p>\n<p>Start by opening MySQL Workbench and establish a connection.<\/p>\n<p><strong>Get the Size for a Single Database<\/strong><\/p>\n<p>1. To get the size of a single database in MySQL Workbench, right-click on the\u00a0<a href=\"https:\/\/phoenixnap.com\/kb\/star-vs-snowflake-schema\" target=\"_blank\" rel=\"noreferrer noopener\">schema<\/a>\u00a0you want to check in the left navigation pane.<\/p>\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-138320 entered lazyloaded\" src=\"https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/mysql-workbench-schema-inspector.png\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" srcset=\"https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/mysql-workbench-schema-inspector.png 800w, https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/mysql-workbench-schema-inspector-300x143.png 300w, https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/mysql-workbench-schema-inspector-768x365.png 768w\" alt=\"MySQL Workbench Schema Inspector\" width=\"800\" height=\"380\" data-lazy-srcset=\"https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/mysql-workbench-schema-inspector.png 800w, https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/mysql-workbench-schema-inspector-300x143.png 300w, https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/mysql-workbench-schema-inspector-768x365.png 768w\" data-lazy-sizes=\"(max-width: 800px) 100vw, 800px\" data-lazy-src=\"https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/mysql-workbench-schema-inspector.png\" data-ll-status=\"loaded\" \/><\/figure>\n<p>2. Select\u00a0<strong>Schema Inspector<\/strong>\u00a0from the list. On the right pane, under the\u00a0<em>Index\u00a0<\/em>tab, check the database size.<\/p>\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-138322 entered lazyloaded\" src=\"https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/mysql-workbench-database-size.png\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" srcset=\"https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/mysql-workbench-database-size.png 800w, https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/mysql-workbench-database-size-300x94.png 300w, https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/mysql-workbench-database-size-768x240.png 768w\" alt=\"MySQL Workbench database size\" width=\"800\" height=\"250\" data-lazy-srcset=\"https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/mysql-workbench-database-size.png 800w, https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/mysql-workbench-database-size-300x94.png 300w, https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/mysql-workbench-database-size-768x240.png 768w\" data-lazy-sizes=\"(max-width: 800px) 100vw, 800px\" data-lazy-src=\"https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/mysql-workbench-database-size.png\" data-ll-status=\"loaded\" \/><\/figure>\n<p>The size is a rough estimate displayed in binary bytes.<\/p>\n<p><strong>Get Table Size for a Single Database<\/strong><\/p>\n<p>To get the size of a table of a specific database:<\/p>\n<p>1. Open the\u00a0<strong>Schema Inspector<\/strong>\u00a0for the database where the table(s) reside.<\/p>\n<p>2. Navigate to the\u00a0<strong>Tables\u00a0<\/strong>tab.<\/p>\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-138323 entered lazyloaded\" src=\"https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/mysql-single-database-table-size.png\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" srcset=\"https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/mysql-single-database-table-size.png 800w, https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/mysql-single-database-table-size-300x128.png 300w, https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/mysql-single-database-table-size-768x326.png 768w\" alt=\"MySQL Workbench single database table size\" width=\"800\" height=\"340\" data-lazy-srcset=\"https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/mysql-single-database-table-size.png 800w, https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/mysql-single-database-table-size-300x128.png 300w, https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/mysql-single-database-table-size-768x326.png 768w\" data-lazy-sizes=\"(max-width: 800px) 100vw, 800px\" data-lazy-src=\"https:\/\/phoenixnap.com\/kb\/wp-content\/uploads\/2021\/09\/mysql-single-database-table-size.png\" data-ll-status=\"loaded\" \/><\/figure>\n<p>3. Check the size of a specific table in the\u00a0<strong>Data Length<\/strong>\u00a0column or add them together to get the total amount. Alternatively, use the\u00a0<strong><code>SELECT<\/code><\/strong>\u00a0statement in a query.<\/p>\n<h2 id=\"ftoc-heading-5\" class=\"ftwp-heading\">Table Size Limits<\/h2>\n<p>MyISAM tables have a default limit set to 256TB for data and index files, which you can change to 65,536TB maximum.<\/p>\n<p>InnoDB maximum size for tables is 256TB, which corresponds to the full tablespace size. Generally, the best practice is to divide an InnoDB table into multiple tablespaces.<\/p>\n<div class=\"notice-note\">\n<div class=\"note-icon-wrapper\"><\/div>\n<div class=\"notice-text\">\n<p><strong>Note:<\/strong>\u00a0Check out our detailed comparison:\u00a0<a href=\"https:\/\/phoenixnap.com\/kb\/myisam-vs-innodb\" target=\"_blank\" rel=\"noopener\">MyISAM vs. InnoDB<\/a><\/p>\n<\/div>\n<\/div>\n<p>Depending on the specifications, some operating systems limit the file size. Although MySQL has some table size limits, a full table error is most likely due to the operating system. Alternatively, the storage where the database resides is possibly at full capacity.<\/p>\n<p class=\"h3\">Conclusion<\/p>\n<p>You should now know several methods to get database and table sizes after following this tutorial. Next, read how to\u00a0<a href=\"https:\/\/phoenixnap.com\/kb\/mysql-optimize-table\" target=\"_blank\" rel=\"noreferrer noopener\">optimize MySQL tables<\/a>\u00a0and other get other\u00a0<a href=\"https:\/\/phoenixnap.com\/kb\/improve-mysql-performance-tuning-optimization\" target=\"_blank\" rel=\"noreferrer noopener\">MySQL Performance Tuning and Optimization Tips<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>How to Check MySQL Database and Table Size There are three ways to check MySQL database and table sizes: 1. Using\u00a0phpMyAdmin. 2. Using the\u00a0SELECT\u00a0statement. 3. Using\u00a0MySQL workbench. All methods provide ways to check the size for: A single database. All databases. Table size for a single database. Table size for all databases. Choose a method [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[13],"tags":[],"class_list":["post-26277","post","type-post","status-publish","format-standard","hentry","category-13"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p6cOVM-6PP","_links":{"self":[{"href":"https:\/\/tom.tomwork.net\/index.php?rest_route=\/wp\/v2\/posts\/26277","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tom.tomwork.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tom.tomwork.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tom.tomwork.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/tom.tomwork.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=26277"}],"version-history":[{"count":1,"href":"https:\/\/tom.tomwork.net\/index.php?rest_route=\/wp\/v2\/posts\/26277\/revisions"}],"predecessor-version":[{"id":26278,"href":"https:\/\/tom.tomwork.net\/index.php?rest_route=\/wp\/v2\/posts\/26277\/revisions\/26278"}],"wp:attachment":[{"href":"https:\/\/tom.tomwork.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=26277"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tom.tomwork.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=26277"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tom.tomwork.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=26277"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}