How to get size of a mysql database?
Suppose the target database is called "v3".
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.
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.
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.
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.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With