回收mysql空间_在mysql中删除数据库后回收磁盘空间

bd96500e110b49cbb3cd949968f18be7.png

I've created some very large databases and have since dropped a few. I've noticed my disk space has not recovered as much as I had expected. For instance, the last database I added actually used up all of my free space and aborted, so I dropped that schema. Before this I had 12.4 GB free, now I only have 7.52 GB free.

What's going on here? How do I get my ~5 GB back?

解决方案Currently, you cannot remove a data file from the tablespace. To decrease the size of your tablespace, use this procedure:

Use mysqldump to dump all your InnoDB tables.

Stop the server.

Remove all the existing tablespace files, including the ibdata and ib_log files. If you want to keep a backup copy of the information, then copy all the ib* files to another location before the removing the files in your MySQL installation.

Remove any .frm files for InnoDB tables.

Configure a new tablespace.

Restart the server.

Import the dump files.

Innodb creates a filesystem (the "tablespace") within the data files themselves. It never "shrinks" the data files when data is removed, since the reorganization of the data within the file could be costly (there's no guarantee that the data removed was at the end, or even contiguous). By recreating the database as described above, it makes the file as large as necessary for all the data, but no larger.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值