mysql 数据文件 缩小,MySQL数据文件不会缩小

My ibdata1 file for MySQL database grew to about 32GB over time. Recently I deleted about 10GB of data from my databases (and restarted mysql for good measure), but the file won't shrink. Is there any way to reduce the size of this file

解决方案

The file size of InnoDB tablespaces will never reduce automatically, no matter how much data you delete.

What you could do, although it is a lot of effort, is to create one tablespace for every table by setting

innodb_file_per_table

The long part about this is, that you need to export ALL DATA from the mysql server (setting up a new server would be easier) and then reimport the data. Instead of one single ibdata1 file which holds the data for each and every table, you will find a lot of files called tablename.ibd which hold the data only for one single table.

Afterwards:

When you then delete a lot of data from tables, you can let mysql recreate the data-file by issuing

alter table engine=myisam;

to switch to MyIsam (and have the InnoDB data file for this table deleted) and then

alter table engine=innodb;

to recreate the table.

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值