Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get size of mysql database?

Tags:

database

mysql

How to get size of a mysql database?
Suppose the target database is called "v3".

like image 979
Newbie Avatar asked Nov 14 '09 06:11

Newbie


People also ask

How do I find the size of a MySQL database?

To check the sizes of all of your databases, at the mysql> prompt type the following command: Copy SELECT table_schema AS "Database", ROUND(SUM(data_length + index_length) / 1024 / 1024, 2) AS "Size (MB)" FROM information_schema.

How do I find the size of a SQL database?

If you need to check a single database, you can quickly find the SQL Server database sizein SQL Server Management Studio (SSMS): Right-click the database and then click Reports -> Standard Reports -> Disk Usage. Alternatively, you can use stored procedures like exec sp_spaceused to get database size.

How do I check the size of a database?

The size of the database is the space the files physically consume on disk. You can find this with: select sum(bytes)/1024/1024 size_in_mb from dba_data_files; But not all this space is necessarily allocated.

What is the size of MySQL?

MyISAM tables have a default limit set to 256TB for data and index files, which you can change to 65,536TB maximum. InnoDB maximum size for tables is 256TB, which corresponds to the full tablespace size.


2 Answers

Run this query and you'll probably get what you're looking for:

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

This query comes from the mysql forums, where there are more comprehensive instructions available.

like image 121
Brian Willis Avatar answered Nov 20 '22 20:11

Brian Willis


It can be determined by using following MySQL command

SELECT table_schema AS "Database", SUM(data_length + index_length) / 1024 / 1024 AS "Size (MB)" FROM information_schema.TABLES GROUP BY table_schema 

Result

Database    Size (MB) db1         11.75678253 db2         9.53125000 test        50.78547382 

Get result in GB

SELECT table_schema AS "Database", SUM(data_length + index_length) / 1024 / 1024 / 1024 AS "Size (GB)" FROM information_schema.TABLES GROUP BY table_schema 
like image 38
Nadeem0035 Avatar answered Nov 20 '22 20:11

Nadeem0035