Languages
[Edit]
EN

MySQL - how to check database size?

14 points
Created by:
AnnLen
1780

Using MySQL querry it is possible to check database size in following way.

1. Size in bytes query example

SELECT 
  `table_schema` AS 'database_name',
  SUM(data_length + index_length) AS 'database_size' 
FROM `information_schema`.`tables `
GROUP BY `table_schema`;

Result:

Database size in bytes MySQL query example - HeidiSQL
Database size in bytes MySQL query example - HeidiSQL

2. Size in kilobytes query example

SELECT 
  `table_schema` AS 'database_name',
  ROUND(SUM(data_length + index_length) / 1024, 2) AS 'database_size' 
FROM `information_schema`.`tables`
GROUP BY `table_schema`;

Result:

Database size in kilobytes MySQL query example - HeidiSQL
Database size in kilobytes MySQL query example - HeidiSQL

2. Size in megabytes query example

SELECT 
  `table_schema` AS 'database_name',
  ROUND(SUM(data_length + index_length) / 1024 / 1024, 2) AS 'database_size' 
FROM `information_schema`.`tables`
GROUP BY `table_schema`;

Result:

Database size in megabytes MySQL query example - HeidiSQL
Database size in megabytes MySQL query example - HeidiSQL
Hey 👋
Would you like to know what we do?
  • Dirask is a friendly IT community for learners, professionals and hobbyists to share their knowledge and help each other in extraordinary easy way.
  • We welcome everyone,
    no matter what the experience,
    no matter how basic the question is,
    this community will help you.