重庆分公司,新征程启航
为企业提供网站建设、域名注册、服务器等服务
这篇文章给大家介绍MySQL怎样查看数据库大小,内容非常详细,感兴趣的小伙伴们可以参考借鉴,希望对大家能有所帮助。
创新互联长期为上千多家客户提供的网站建设服务,团队从业经验10年,关注不同地域、不同群体,并针对不同对象提供差异化的产品和服务;打造开放共赢平台,与合作伙伴共同营造健康的互联网生态环境。为吉州企业提供专业的成都网站制作、网站设计,吉州网站改版等技术服务。拥有10余年丰富建站经验和众多成功案例,为您定制开发。
1 命令行进入数据库
[root@80 ~]# mysql -uroot -p Enter password:
2 查看数据库
mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | test | +--------------------+
3 查看information_schema的"TABLES"
mysql> use information_schema; | TABLES |
4 查看字段结构
mysql> desc tables; +-----------------+---------------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-----------------+---------------------+------+-----+---------+-------+ | TABLE_CATALOG | varchar(512) | NO | | | | | TABLE_SCHEMA | varchar(64) | NO | | | | | TABLE_NAME | varchar(64) | NO | | | | | TABLE_TYPE | varchar(64) | NO | | | | | ENGINE | varchar(64) | YES | | NULL | | | VERSION | bigint(21) unsigned | YES | | NULL | | | ROW_FORMAT | varchar(10) | YES | | NULL | | | TABLE_ROWS | bigint(21) unsigned | YES | | NULL | | | AVG_ROW_LENGTH | bigint(21) unsigned | YES | | NULL | | | DATA_LENGTH | bigint(21) unsigned | YES | | NULL | | | MAX_DATA_LENGTH | bigint(21) unsigned | YES | | NULL | | | INDEX_LENGTH | bigint(21) unsigned | YES | | NULL | | | DATA_FREE | bigint(21) unsigned | YES | | NULL | | | AUTO_INCREMENT | bigint(21) unsigned | YES | | NULL | | | CREATE_TIME | datetime | YES | | NULL | | | UPDATE_TIME | datetime | YES | | NULL | | | CHECK_TIME | datetime | YES | | NULL | | | TABLE_COLLATION | varchar(32) | YES | | NULL | | | CHECKSUM | bigint(21) unsigned | YES | | NULL | | | CREATE_OPTIONS | varchar(255) | YES | | NULL | | | TABLE_COMMENT | varchar(2048) | NO | | | | +-----------------+---------------------+------+-----+---------+-------+
5 查看DB的数据大小
mysql> select table_schema,round(sum(DATA_LENGTH)/1024/1024,2) as table_size from tables group by table_schema; +--------------------+------------+ | table_schema | table_size | +--------------------+------------+ | bomo_backend | 0.09 | | test1 | 234.16 | | test2 | 0.17 | | information_schema | 0.00 | | mysql | 0.71 | | performance_schema | 0.00 | | test | 0.03 | +--------------------+------------+
6 查看table的数据大小
mysql> select table_schema,table_name,concat(round(data_length/1024/1024,2),'M') as table_size from tables where table_schema = 'grab'; +--------------+--------------+------------+ | table_schema | table_name | table_size | +--------------+--------------+------------+ | grab | product | 215.12M | | grab | result | 13.52M | | grab | rule | 0.02M | | grab | task | 5.52M | +--------------+--------------+------------+
关于Mysql怎样查看数据库大小就分享到这里了,希望以上内容可以对大家有一定的帮助,可以学到更多知识。如果觉得文章不错,可以把它分享出去让更多的人看到。