行业资讯

mysql查看数据库大小以及使用情况?

推荐: 仿站 香港服务器 香港站群服务器 美国服务器 美国站群服务器 日本站群服务器

用SQL命令查看Mysql数据库大小:

要想知道每个数据库的大小的话,步骤如下:

1、进入information_schema 数据库(存放了其他的数据库的信息)

use information_schema;

2、查询所有数据的大小:

select concat(round(sum(data_length/1024/1024),2),'MB') as data from tables;

3、查看指定数据库的大小:

比如查看数据库home的大小

select concat(round(sum(data_length/1024/1024),2),'MB') as data from tables where table_schema='home';

4、查看指定数据库的某个表的大小

比如查看数据库home中 members 表的大小

select concat(round(sum(data_length/1024/1024),2),'MB') as data from tables where table_schema='home' and table_name='members';

查看MySQL数据库空间使用情况:

information_schema是MySQL的系统数据库,information_schema里的tables表存放了整个数据库各个表的使用情况。

可以使用sql来统计出数据库的空间使用情况,相关字段:

table_schema:数据库名

table_name:表名

table_rows:记录数

data_length:数据大小

index_length:索引大小

1、统计表使用空间

mysql> select concat(round(sum(data_length/1024/1024),2),'mb') as data from tables where table_schema='mydb' and table_name='mytable';

| data |

| 0.02mb |

1 row in set (0.00 sec)

2、统计数据库使用空间

mysql> select concat(round(sum(data_length/1024/1024),2),'MB') as data from tables where table_schema='mydb';

| data |

| 6.64MB |

1 row in set (0.00 sec)

3、统计所有数据使用空间

mysql> select concat(round(sum(data_length/1024/1024),2),'MB') as data from tables;

| data |

| 6.64MB |

1 row in set (0.01 sec)

以上就是mysql查看数据库大小以及使用情况的全部内容,供大家参考!

王牌服务器专业提供海外云服务器租用、动态拨号vps服务器租用、gpu显卡服务器租用、站群服务器租用、高防服务器租用、CN2服务器租用、bgp服务器租用等,有需要的朋友可以咨询我们,官网:http://www.zonghengcloud.com/,TG:Ammkiss

上一篇: 香港服务器链接国内数据库做网站速度会更快吗?

下一篇: Windows server 2012开防火墙如何远程?

我司服务器均免费真机测试,不满意不收取任何费用

申请试用
  • 24H在线
  • Tg纸飞机