Today, databases are used almost everywhere, especially large companies and application development teams need them. If you decide to make a website, you will not be able to build its effective and proper operation without a database. You will need it to store dynamically changing information. Usually it is one of the most popular databases - MariaDB or MySQL.
But how much does your database take up? For large projects, these figures can reach very large values. In this article we will talk about how to find out the size of MySQL database through the console and other ways.
The database that is installed in Linux is checked in a simple way. The instructions that we will follow below are suitable for most other operating systems. The easiest way to estimate how much space all databases take up is to look at the size of the folder with the database files on the system - /var/lib/mysql
:
$ du -h /var/lib/mysql
The command allows you to find out the size of the Mysql database in megabytes. But it will be much more correct to look at information about the database using its built-in tools. MySQL has a special table for this purpose - Information_schema. First of all, before using it, you need to make a connection to the database:
$ mysql -u root -p
SELECT table_schema AS "Base name",
ROUND(SUM(data_length + index_length) / 1024 / 1024, 2) AS "Size in MB"
FROM information_schema.TABLES
GROUP BY table_schema;
By this query will display information about the size of the MySQL database for each, the user will be able to navigate and understand which database how much space it takes up. If you have a very large project and a large database, you can output information in gigabytes:
SELECT table_schema AS "Base name",
ROUND(SUM(data_length + index_length) / 1024 / 1024 / 1024, 2) AS "Size in GB"
FROM information_schema.TABLES
GROUP BY table_schema;
But that's not all. There might be unnecessary information in the database that is only slowing down the system. We can see the size of the tables for each of the databases. The query for this will look like this:
SELECT table_name AS "Table name",
ROUND(((data_length + index_length) / 1024 / 1024), 2) AS "Size in (MB)"
FROM information_schema.TABLES
WHERE table_schema = "wpfc_options"
ORDER BY (data_length + index_length) DESC;
The information will help us understand which table occupies how much and this can already give us some interesting insights.
Many users don't like or don't want to work in the terminal. This is not a big problem as you can use Phpmyadmin to view the size of the database.
You can see the size of each of the database tables on the "Structure" tab when you select a database to work on.
As for the size of the database itself, you will have to run the same query in the program interface on the "SQL" tab:
Apply the discount by inserting the promo code in the special field at checkout:
Apply the discount by inserting the promo code in the special field at checkout: