To check the disk usage of a specific MySQL database, you can use the following query. This query will give you the total disk space consumed by both the data and index files of the specified database.
Query to Check MySQL Database Usage:
Explanation:
table_schema
: Represents the name of the database.data_length
: The space used by the data (tables).index_length
: The space used by the indexes.SUM(data_length + index_length)
: Total space used by the data and indexes./ 1024 / 1024
: Converts the value from bytes to megabytes (MB).
Example:
If your database name is my_database
, the query would look like this:
Output:
This query will return the total disk space (in MB) that the specified database is using on the filesystem.