How to view the size of a database in MySQL?

To check the size of a MySQL database, you can use the following method:

1. SQL Query Usage: You can execute the following SQL query to retrieve information about the size of the database:

SELECT table_schema "Database",
       ROUND(SUM(data_length + index_length) / 1024 / 1024, 2) "Size in MB"
FROM information_schema.tables
GROUP BY table_schema;

This will return the names and sizes (in MB) of each database.

Using the MySQL command line tool: You can use the MySQL command line tool to retrieve information about the size of the database. Run the following command in the command line:

mysql -u  -p -e "SELECT table_schema 'Database', SUM(data_length + index_length)/1024/1024 '
Size in MB' FROM information_schema.tables GROUP BY table_schema;"

Replace `` with your MySQL username. The system will prompt you to enter your password. It will then return the name and size of each database.

3. Utilize MySQL graphical tools: If you are using a MySQL graphical management tool (such as phpMyAdmin, MySQL Workbench, etc.), there is typically an interface or option that displays the size of the database. You can refer to the tool’s documentation or help files for more information.

No matter which method you choose, you will be able to obtain information about the size of the MySQL database.

Leave a Reply 0

Your email address will not be published. Required fields are marked *


广告
Closing in 10 seconds
bannerAds