mysql error :1114 - The table ‘XXX‘ is full

背景

因为本地测试库的一张表数据不需要了,想要使用truncate进行删除。执行操作:TRUNCATE shop.user; 时提示:1114 - The table ‘user’ is full, Time: 0.008000s

原因

根据上面提示信息解释为:表user已经满了。其实是因为删除操作,磁盘可用空间需要大于表本身占据的空间(比如当前操作的表占据 2 GB,那么要求磁盘可用空间必须大于 2 GB)。

我们先来查看一下磁盘空间情况:

[root@dxm22 ~]# df -h

在这里插入图片描述
找到了执行truncate失败的原因是磁盘空间已满。

解决办法

解决办法一:既然确定是磁盘空间已满,我们来释放一点空间再试试。
我们先用find / -xdev -size +100M -exec ls -lh {} \; 来查看磁盘空间的占用情况,然后找到不用的文件进行删除。

然后再执行TRUNCATE shop.user; 进行删除。我这里是删除成功了。如果不能删除成功,可以继续往下看。

解决办法二:找到my.cnf配置文件,设置 tmp_table_size 大于 max_heap_table_size即可。
操作步骤如下:

  1. 先查看现配置的tmp_table_size和max_heap_table_size的参数值。
root@db 10:22:  [shop]> show variables like '%table_size%';

在这里插入图片描述

  1. 修改my.cnf 配置文件中tmp_table_size和max_heap_table_size这两个参数。
[root@dxm22 ~]# vim /etc/my.cnf

在这里插入图片描述

  1. 重启 mysql服务。
[root@dxm22 ~]# systemctl restart mysql.service

执行完重启命令之后,再来查看一下服务状态:

[root@dxm22 ~]# systemctl status mysql.service

在这里插入图片描述
Active: active (running)说明服务重启成功

  1. 再次查看tmp_table_size和max_heap_table_size这两个参数值,验证配置是否生效。
root@db 10:31:  [shop]> show variables like '%table_size%';

在这里插入图片描述
看到tmp_table_size值已经更新,说明配置生效了。

  1. 再执行truncate操作。
    再执行TRUNCATE shop.user;即可成功。在这里插入图片描述
  • 4
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
MySQL error 1114 is related to the InnoDB storage engine and it means that the table is full. This error occurs when the InnoDB engine cannot allocate more space to store data in the table. Here are some steps you can take to resolve this error: 1. Check the available disk space on your server. If the disk space is low, free up some space. 2. Check the size of the table that is causing the error. You can use the following command to get the size of the table: ``` SELECT table_name, round(((data_length + index_length) / 1024 / 1024), 2) as "Size (MB)" FROM information_schema.TABLES WHERE table_schema = "your_database_name" ORDER BY (data_length + index_length) DESC; ``` This will give you the size of all the tables in your database. Identify the table that is causing the error and check if it has reached its maximum size limit. 3. Increase the maximum size limit for the table. You can do this by altering the table and increasing the value of the `innodb_data_file_path` parameter. For example: ``` ALTER TABLE your_table_name ENGINE=InnoDB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=8 MAX_ROWS=100000 AVG_ROW_LENGTH=10000 DATA DIRECTORY='/path/to/new/directory/' INDEX DIRECTORY='/path/to/new/directory/' PARTITION BY KEY(id) PARTITIONS 10 COMMENT='Increase table size limit'; ``` In this example, the `MAX_ROWS` and `AVG_ROW_LENGTH` parameters have been increased to increase the table size limit. You can adjust these parameters according to your needs. 4. If none of the above solutions work, you can try optimizing the table. This will free up some space and may resolve the error. You can use the following command to optimize a table: ``` OPTIMIZE TABLE your_table_name; ``` This will rebuild the table and reclaim any unused space. I hope these solutions help you resolve the MySQL error 1114.

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值