Узнаём размер БД через консоль MySQL
Было ли у вас такое, что Вам необходимо узнать размер БД в консоли mysql? Если у Вас именно тот случай — то рассмотрим, как это сделать.
А сделать это очень просто, нам понадобится всего лишь выполнить 1 запрос в консоли MySQL, который выглядит вот так:
В ответ мы получим примерно следующее:
Если у вас очень большая база, как в моем случае, то можно получить ответ не в МБ, а в ГБ, для этого выполним вот такой запрос:
И в ответ получим что то типа такого:
Если у Вас есть еще вопросы или предложения по заметке — приглашаю Вас в комментарии!
How to check MySQL database and table sizes
This article demonstrates how to check the size of MySQL databases and tables. You can do this by using the phpMyAdmin web interface or by using the command-line mysql program.
Using phpMyAdmin
You can use the phpMyAdmin web interface to check the sizes of MySQL databases and tables. To do this, follow these steps:
-
Log in to cPanel.
The phpMyAdmin administration page appears in a new window.
In the right pane, locate the Size column. phpMyAdmin lists the size of each table in the database:

To obtain the total size of the database, scroll down to the end of the Size column:

Using the mysql command-line program
You can use the mysql command-line program to check the sizes of MySQL databases and tables. To do this, follow these steps:
- Log in to your account using SSH.
- At the command line, type the following command, replacing username with your A2 Hosting account username:
- At the Enter Password prompt, type your password. When you type the correct password, the mysql> prompt appears.
To check the sizes of all of your databases, at the mysql> prompt type the following command:
To check the sizes of all of the tables in a specific database, at the mysql> prompt, type the following command. Replace database_name with the name of the database that you want to check:
Sorry, you have been blocked
This website is using a security service to protect itself from online attacks. The action you just performed triggered the security solution. There are several actions that could trigger this block including submitting a certain word or phrase, a SQL command or malformed data.
What can I do to resolve this?
You can email the site owner to let them know you were blocked. Please include what you were doing when this page came up and the Cloudflare Ray ID found at the bottom of this page.
Cloudflare Ray ID: 7f0961bdaf9f2ff2 • Your IP: Click to reveal 178.132.111.46 • Performance & security by Cloudflare
How to Check the Size of a Database in MySQL
In MySQL, you can query the information_schema.tables table to return information about the tables in a database. This table includes information about the data length, index length, as well as other details such as collation, creation time, etc. You can use the information in this table to find the size of a given database or all databases on the server.
You can also use the MySQL Workbench GUI to find details about the database (including its size).
This article provides a quick overview of both methods.
Code Example
Here’s an example of finding the size of each database by running a query against the information_schema.tables table:
In this example I’ve listed the size in bytes and in mebibytes (MiB), but you can choose how you want to present it.
Of course, you can always narrow it down to a specific database if you need to. Simply add a WHERE clause with the name of the database:
The FORMAT_BYTES() Function
You can use the FORMAT_BYTES() function to save yourself converting the size into mebibytes, kibibytes, or whatever. This function takes a value, converts it to human-readable format and returns a string consisting of a value and a units indicator. The converted value will depend on the size of the value (so the result could be in bytes , KiB (kibibytes), MiB (mebibytes), GiB (gibibytes), TiB (tebibytes), PiB (pebibytes), or EiB (exbibytes).
Here’s an example of rewriting the previous example to use the FORMAT_BYTES() function:
MySQL Workbench
Another way of finding the database size is to use the MySQL Workbench GUI. Here’s how: