mar*_*vin 143 mysql database size storage byte
我想知道我的MySQL数据库使用了多少空间,以便选择一个Web主机.我发现命令SHOW TABLE STATUS LIKE 'table_name'
所以当我进行查询时,我得到这样的东西:
Name | Rows | Avg. Row Length | Data_Length | Index Length
---------- ---- --------------- ----------- ------------
table_name 400 55 362000 66560
Run Code Online (Sandbox Code Playgroud)
那么这张表有362000 或400*362000 = 144800000字节的数据吗?索引长度是什么意思?谢谢 !
小智 278
来自S. Prakash,在MySQL论坛上找到:
SELECT table_schema "database name",
sum( data_length + index_length ) / 1024 / 1024 "database size in MB",
sum( data_free )/ 1024 / 1024 "free space in MB"
FROM information_schema.TABLES
GROUP BY table_schema;
Run Code Online (Sandbox Code Playgroud)
或者在一行中更容易复制粘贴:
SELECT table_schema "database name", sum( data_length + index_length ) / 1024 / 1024 "database size in MB", sum( data_free )/ 1024 / 1024 "free space in MB" FROM information_schema.TABLES GROUP BY table_schema;
Run Code Online (Sandbox Code Playgroud)
min*_*s23 92
您可以通过在Mysql客户端中运行以下命令来获取Mysql数据库的大小
SELECT sum(round(((data_length + index_length) / 1024 / 1024 / 1024), 2)) as "Size in GB"
FROM information_schema.TABLES
WHERE table_schema = "<database_name>"
Run Code Online (Sandbox Code Playgroud)
Rad*_*zea 29
如果您使用phpMyAdmin,它可以告诉您这些信息.
只需转到"数据库"(顶部的菜单),然后单击"启用统计信息".
你会看到这样的东西:
随着尺寸的增加,这可能会失去一些准确性,但它应该足够准确,以满足您的需要.
小智 8
如果你想以MB为单位找到它
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;
Run Code Online (Sandbox Code Playgroud)
小智 4
基本上有两种方法:查询DB(数据长度+索引长度)或检查文件大小。索引长度与索引中存储的数据有关。
一切都在这里描述:
http://www.mkyong.com/mysql/how-to-calculate-the-mysql-database-size/
归档时间: |
|
查看次数: |
197664 次 |
最近记录: |