查询数据表空间占用
mysql> select truncate((data_length/1024/1024), 2) as '数据表占用空间', truncate((index_length/1024/1024), 2) as '数据索引占用空间(mb)', truncate((data_free/1024/1024), 2) as '数据碎片占用空间(mb)' , table_name as '数据表名' from information_schema.tables where table_schema like 'ws%';
查询数据库空间占用
mysql> select table_schema as '数据库', sum(table_rows) as '记录数', sum(truncate(data_length/1024/1024, 2)) as '数据容量(mb)', sum(truncate(index_length/1024/1024, 2)) as '索引容量(mb)', sum(truncate(data_free/1024/1024, 2)) as '碎片占用(mb)' from information_schema.tables where table_schema = 'ws' group by table_schema;
查询MySQL进程占用空间
root@localhost> ps -ef | grep [进程名称]
root@localhost> htop -p [进程pid]