{"id":13900,"date":"2023-01-23T06:51:28","date_gmt":"2023-01-23T06:51:28","guid":{"rendered":"http:\/\/www.appservgrid.com\/paw92\/?p=13900"},"modified":"2023-01-23T06:51:30","modified_gmt":"2023-01-23T06:51:30","slug":"how-to-check-mysql-database-size-in-linux","status":"publish","type":"post","link":"https:\/\/www.appservgrid.com\/paw92\/index.php\/2023\/01\/23\/how-to-check-mysql-database-size-in-linux\/","title":{"rendered":"How to Check MySQL Database Size in Linux"},"content":{"rendered":"<p>In this article, I will show you how to check the size of&nbsp;<strong>MySQL\/MariaDB<\/strong>&nbsp;databases and tables via the MySQL shell. You will learn how to determine the real size of a database file on the disk as well as size of data that it present in a database.<\/p>\n<p><strong>Read Also<\/strong>:&nbsp;<a href=\"https:\/\/www.tecmint.com\/mysqladmin-commands-for-database-administration-in-linux\/\" target=\"_blank\" rel=\"noopener\">20 MySQL (Mysqladmin) Commands for Database Administration in Linux<\/a><\/p>\n<p>By default&nbsp;<strong>MySQL\/MariaDB<\/strong>&nbsp;stores all the data in the file system, and the size of data that exists on the databases may differ from the actual size of Mysql data on the disk that we will see later on.<\/p>\n<p>In addition, MySQL uses the&nbsp;<strong>information_schema<\/strong>&nbsp;virtual database to store information about your databases and other settings. You can query it to gather information about size of databases and their tables as shown.<\/p>\n<pre># mysql -u root -p\n<strong>MariaDB [(none)]&gt;<\/strong> SELECT table_schema AS \"Database Name\", \nROUND(SUM(data_length + index_length) \/ 1024 \/ 1024, 2) AS \"Size in (MB)\" \nFROM information_schema.TABLES \nGROUP BY table_schema; \n<\/pre>\n<div id=\"attachment_28216\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/12\/Check-MySQL-Database-Size.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-28216\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/12\/Check-MySQL-Database-Size.png\" sizes=\"auto, (max-width: 822px) 100vw, 822px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/12\/Check-MySQL-Database-Size.png 822w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/12\/Check-MySQL-Database-Size-768x286.png 768w\" alt=\"Check MySQL Database Size\" width=\"822\" height=\"306\" aria-describedby=\"caption-attachment-28216\" data-lazy-loaded=\"true\"><\/a><\/p>\n<p id=\"caption-attachment-28216\" class=\"wp-caption-text\">Check MySQL Database Size<\/p>\n<\/div>\n<p>To find out the size of a single MySQL database called&nbsp;<strong>rcubemail<\/strong>&nbsp;(which displays the size of all tables in it) use the following mysql query.<\/p>\n<pre><strong>MariaDB [(none)]&gt;<\/strong> SELECT table_name AS \"Table Name\",\nROUND(((data_length + index_length) \/ 1024 \/ 1024), 2) AS \"Size in (MB)\"\nFROM information_schema.TABLES\nWHERE table_schema = \"<strong>rcubemail<\/strong>\"\nORDER BY (data_length + index_length) DESC;\n<\/pre>\n<div id=\"attachment_28217\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/12\/Check-Size-of-MySQL-Database.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-28217\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/12\/Check-Size-of-MySQL-Database.png\" sizes=\"auto, (max-width: 802px) 100vw, 802px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/12\/Check-Size-of-MySQL-Database.png 802w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/12\/Check-Size-of-MySQL-Database-768x475.png 768w\" alt=\"Check Size of MySQL Database\" width=\"802\" height=\"496\" aria-describedby=\"caption-attachment-28217\" data-lazy-loaded=\"true\"><\/a><\/p>\n<p id=\"caption-attachment-28217\" class=\"wp-caption-text\">Check Size of MySQL Database<\/p>\n<\/div>\n<p>Finally, to find out the actual size of all MySQL database files on the disk (filesystem), run the&nbsp;<a href=\"https:\/\/www.tecmint.com\/check-linux-disk-usage-of-files-and-directories\/\" target=\"_blank\" rel=\"noopener\">du command<\/a>below.<\/p>\n<pre># du -h \/var\/lib\/mysql\n<\/pre>\n<div id=\"attachment_28218\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/12\/Check-MySQL-Size-on-Disk.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-28218\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/12\/Check-MySQL-Size-on-Disk.png\" alt=\"Check MySQL Size on Disk\" width=\"522\" height=\"135\" aria-describedby=\"caption-attachment-28218\" data-lazy-loaded=\"true\"><\/a><\/p>\n<p id=\"caption-attachment-28218\" class=\"wp-caption-text\">Check MySQL Size on Disk<\/p>\n<\/div>\n<p>You might also like to read these following MySQL related articles.<\/p>\n<ol>\n<li><a href=\"https:\/\/www.tecmint.com\/mysql-performance-monitoring\/\" target=\"_blank\" rel=\"noopener\">4 Useful Commandline Tools to Monitor MySQL Performance in Linux<\/a><\/li>\n<li><a href=\"https:\/\/www.tecmint.com\/mysql-mariadb-security-best-practices-for-linux\/\" target=\"_blank\" rel=\"noopener\">12 MySQL\/MariaDB Security Best Practices for Linux<\/a><\/li>\n<\/ol>\n<p>For any queries or additional ideas you want to share regarding this topic, use the feedback form below.<\/p>\n<p><a href=\"https:\/\/www.tecmint.com\/check-mysql-database-size-in-linux\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this article, I will show you how to check the size of&nbsp;MySQL\/MariaDB&nbsp;databases and tables via the MySQL shell. You will learn how to determine the real size of a database file on the disk as well as size of data that it present in a database. Read Also:&nbsp;20 MySQL (Mysqladmin) Commands for Database Administration &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.appservgrid.com\/paw92\/index.php\/2023\/01\/23\/how-to-check-mysql-database-size-in-linux\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;How to Check MySQL Database Size in Linux&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-13900","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/13900","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/comments?post=13900"}],"version-history":[{"count":2,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/13900\/revisions"}],"predecessor-version":[{"id":16917,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/13900\/revisions\/16917"}],"wp:attachment":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/media?parent=13900"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/categories?post=13900"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/tags?post=13900"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}