网上找的一个,亲测可用:
//先进去MySQL自带管理库:information_schema
//然后查询 data_length,index_length
//你自己的数据库名:dbname
//你自己的表名:tablename
mysql> use information_schema;
Database changed
mysql> select data_length,index_length
-> from tables where
-> table_schema='dbname'
-> and table_name = 'tablename';
+-------------+--------------+
| data_length | index_length |
+-------------+--------------+
| 166379520 | 235782144 |
+-------------+--------------+
row in set (0.02 sec)
mysql> select concat(round(sum(data_length/1024/1024),2),'MB') as data_length_MB,
-> concat(round(sum(index_length/1024/1024),2),'MB') as index_length_MB
-> from tables where
-> table_schema='dbname'
-> and table_name = 'tablename';
+----------------+-----------------+
| data_length_MB | index_length_MB |
+----------------+-----------------+
| 158.67MB | 224.86MB |
+----------------+-----------------+
row in set (0.03 sec)