How can I check the size of a database in MySQL?
There are several methods available to check the size of a MySQL database.
- Use the command line tool: Enter the following commands in the command line.
SELECT table_schema AS "数据库",
ROUND(SUM(data_length + index_length) / 1024 / 1024, 2) AS "大小(MB)"
FROM information_schema.TABLES
GROUP BY table_schema;
The above command will display the size of each database in megabytes.
- To use MySQL Workbench, open the program and connect to your MySQL server, then select the “Management” tab on the left panel. In the “Server Status” section, you can view the size of each database.
- To use phpMyAdmin, open it and select your MySQL server. Then, go to the “Databases” tab on the left panel. In the right panel, you will see the size of each database.
You can easily view the size of a MySQL database regardless of the method you choose.