mysql 查看数据大小

Zabbix服务器运行一段事件后,查看zabbix服务占用了多大的数据存储空间。

最简单的方式,直接查看全局的,如下所示:

[plain] view plain copy
mysql> use information_schema;  
Reading table information for completion of table and column names  
You can turn off this feature to get a quicker startup with -A  

Database changed  
mysql> select concat(round(sum(DATA_LENGTH/1024/1024),2), 'MB') as data from TABLES;  
+-----------+  
| data      |  
+-----------+  
| 5516.40MB |  
+-----------+  
1 row in set (0.16 sec)  

mysql>  

如果只想查看Zabbix数据库

[plain] view plain copy
mysql> show databases;  
+--------------------+  
| Database           |  
+--------------------+  
| information_schema |  
| mysql              |  
| test               |  
| zabbix             |  
+--------------------+  
4 rows in set (0.00 sec)  

mysql> select sum(DATA_LENGTH)+sum(INDEX_LENGTH) from information_schema.tables where table_schema='zabbix';  
+------------------------------------+  
| sum(DATA_LENGTH)+sum(INDEX_LENGTH) |  
+------------------------------------+  
|                         9501360128 |  
+------------------------------------+  
1 row in set (0.09 sec)  

mysql> select concat(round(sum(DATA_LENGTH)/1024/1024+sum(INDEX_LENGTH)/1024/1024),'M') from information_schema.tables where table_schema='zabbix';  
+---------------------------------------------------------------------------+  
| concat(round(sum(DATA_LENGTH)/1024/1024+sum(INDEX_LENGTH)/1024/1024),'M') |  
+---------------------------------------------------------------------------+  
| 9063M                                                                     |  
+---------------------------------------------------------------------------+  
1 row in set (0.10 sec)  

mysql>  

还可以参考另外一个文章:http://blog.csdn.net/oscar999/article/details/7221091

猜你喜欢

转载自blog.csdn.net/rainbowzhouj/article/details/79867963