1、配置中加上skip-new重启mysql,让innodb支持optimize

systemctl stop mysqld
systemctl start mysqld
image.png

2、optimize table miner_profit_detail_user

  1. CREATE DEFINER=`root`@`%` PROCEDURE `optimize_table`()
  2. BEGIN
  3. declare table_count int default 50;
  4. declare table_count_now int default 1;
  5. set @strSql = "";
  6. while table_count_now <= table_count do
  7. #优化指定的表
  8. set @strSql = concat("optimize table miner_profit_detail_user_",table_count_now," ;");
  9. set table_count_now = table_count_now+1;
  10. PREPARE stmt FROM @strSql;
  11. EXECUTE stmt;
  12. deallocate prepare stmt;
  13. end while;
  14. END

3、df -h查看空间变化