MySQL插入大批量数据时报错“The total number of locks exceeds the lock table size”的解决办法
事情的原因是:我执行了一个load into语句的SQL将一个很大的文件导入到我的MySQL数据库中,执行了一段时间后报错“The total number of locks exceeds the lock table size”。
首先使用命令 show variables like '%storage_engine%' 查看MySQL的存储引擎:
mysql> show variables like '%storage_engine%';
+----------------------------------+--------+
| Variable_name | Value |
+----------------------------------+--------+
| default_storage_engine | InnoDB |
| default_tmp_storage_engine | InnoDB |
| disabled_storage_engines | |
| internal_tmp_disk_storage_engine | InnoDB |
+----------------------------------+--------+
4 rows in set, 1 warning (0.00 sec)
可以看到InnoDB是MySQL的默认引擎。
报错“The total number of locks exceeds the lock table size”说明MySQL的默认配置已经无法满足你的需求了,
InnoDB表执行大批量数据的更新,插入,删除操作时会出现这个问题,
需要调整InnoDB全局的innodb_buffer_pool_size的值来解决这个问题,并且重启mysql服务。
首先我们通过命令 show variables like "%_buffer_pool_size%" 查看MySQL缓存池的大小:
mysql> show variables like "%_buffer_pool_size%";
+-------------------------+---------+
| Variable_name | Value |
+-------------------------+---------+
| innodb_buffer_pool_size | 8388608 |
+-------------------------+---------+
1 row in set, 1 warning (0.00 sec)
可以看到,默认的缓存池大小是 8388608 = 8 * 1024 * 1024 = 8 MB。我们需要把它改大一点。
那么到底是多少呢,就是说你剩多少内存,用多少内存咯,我估计我有个3个G的内存可以用,
那么我可以将innodb_buffer_pool_size的值设成310241024*1024=3221225472。
然后我们配置一下``文件(MySQL Installer安装的话,这个是配置文件的默认位置),将
innodb_buffer_pool_size=8M
修改为:
innodb_buffer_pool_size=3G
对于这个值的配置,其实在配置文件中也给了说明:
# InnoDB, unlike MyISAM, uses a buffer pool to cache both indexes and
# row data. The bigger you set this the less disk I/O is needed to
# access data in tables. On a dedicated database server you may set this
# parameter up to 80% of the machine physical memory size. Do not set it
# too large, though, because competition of the physical memory may
# cause paging in the operating system. Note that on 32bit systems you
# might be limited to 2-3.5G of user level memory per process, so do not
# set it too high.
然后重启mysqld服务。(可通过命令行执行services.msc进入服务窗口)
然后在命令行执行命令查看此时的缓存池大小:
mysql> show variables like "%_buffer_pool_size%";
+-------------------------+------------+
| Variable_name | Value |
+-------------------------+------------+
| innodb_buffer_pool_size | 3221225472 |
+-------------------------+------------+
1 row in set, 1 warning (0.00 sec)
可以看到这个值已经修改成了我们想要的大小 —— 3GB。
再次运行我的导入文件的SQL,发现可以了,而且还很快呢。
但是内存也是有些吃紧的。

MySQL插入大批量数据时报错“The total number of locks exceeds the lock table size”的解决办法的更多相关文章
- 【MySQL笔记】mysql报错"ERROR 1206 (HY000): The total number of locks exceeds the lock table size"的解决方法
step1:查看 1.1 Mysql命令行里输入"show engines:"查看innoddb数据引擎状态, 1.2 show variables "%_buffer% ...
- mysql报错"ERROR 1206 (HY000): The total number of locks exceeds the lock table size"的解决方法
1. 问题背景 InnoDB是新版MySQL(v5.5及以后)默认的存储引擎,之前版本的默认引擎为MyISAM,因此,低于5.5版本的mysql配置文件.my.cnf中,关于InnoD ...
- MySQL配置文件路径及‘The total number of locks exceeds the lock table size’问题
在删除mysql中的数据时,遇到报错: ERROR 1206 (HY000): The total number of locks exceeds the lock table size 查了查,发现 ...
- mysql 数据库缓存调优之解决The total number of locks exceeds the lock table size错误
环境: mysql5.6.2 主从同步(备注:需操作主库和从库) 一.InnoDB表执行大批量数据的更新,插入,删除操作时会出现这个问题,需要调整InnoDB全局的innodb_buffer_poo ...
- MYSQL 遭遇 THE TOTAL NUMBER OF LOCKS EXCEEDS THE LOCK TABLE SIZE
今天进行MySql 一个表数据的清理,经过漫长等待后出现 The total number of locks exceeds the lock table size 提示.以为是table_cache ...
- mysql:The total number of locks exceeds the lock table size
使用mysql InnoDB存储引擎进行大量数据的更新,删除的时候容易引发”The total number of locks exceeds the lock table size”问题,解决方法之 ...
- MySQL解决[Err] 1206 - The total number of locks exceeds the lock table size问题
MySQL解决[Err] 1206 - The total number of locks exceeds the lock table size问题 查看MySQL版本:mysql>show ...
- MYSQL碰到The total number of locks exceeds the lock table size 问题解决记录
解决记录如下: 在mysql里面进行修改操作时提示:The total number of locks exceeds the lock table size ,通过百度搜到innodb_buffer ...
- Mysql_解决The total number of locks exceeds the lock table size错误
在操作mysql数据库表时出现以下错误. 网上google搜索相关问题,发现一位外国牛人这么解释: If you're running an operation on a large number o ...
随机推荐
- learning java AWT 布局管理器BorderLayout
BorderLayout 将容器分为EAST, SOUTH, WEST,NORTH,CENTER五个区域. public class BorderLayoutTest { public static ...
- am335x system upgrade kernel i2c rtc eeprom(六)
1 Scope of Document This document describes i2c bus hardware design and support i2c-devices: ee ...
- Codevs 3160 最长公共子串(后缀数组)
3160 最长公共子串 时间限制: 2 s 空间限制: 128000 KB 题目等级 : 大师 Master 题目描述 Description 给出两个由小写字母组成的字符串,求它们的最长公共子串的长 ...
- PageHelper的问题
如果分页语句没有被消耗掉,它一直保留着,直到被织入到下一次查询语句,如果 被织入的查询语句自己有LIMIT限制,那么两个LIMIT就导致语法错误了. PageHelper.startPage(page ...
- UOJ#401. 【CTSC2018】青蕈领主 分治,FFT
原文链接www.cnblogs.com/zhouzhendong/p/UOJ401.html 题解 首先,对于一个排列,它的连续段一定只有包含关系,没有相交关系. 我们可以据此得到一棵表示连续段的树. ...
- 北漂IT男返乡2年的三线楼市观察(宜昌夷陵篇)-原创
一直想写点什么,这段时间总算有空,好嘞,正好有兴致来写一写楼市相关的文章以饕读者和粉丝朋友. 宜昌?说宜昌您可能不知道,但是说三峡大坝您就知道了 最近这两年,因为小宝的降临,我多半时间待在老家宜昌陪伴 ...
- arcpy模块下的并行计算与大规模数据处理
一个多星期的时间,忍着胃痛一直在做GIS 540: Spatial Programming的课程项目,导致其他方面均毫无进展,可惜可惜.在这个过程当中临时抱佛脚学习了很多Python相关的其他内容,并 ...
- CentOS 安装抓包工具wireshark-tshark抓包工具
原文出处:razeen -> https://razeen.me/post/how-to-install-tshark-on-centos.html 准备在服务器上用tshark抓包,分析一下数 ...
- 【转】分享一款颜色神器ColorSchemer Studio
原文:https://www.cnblogs.com/xyfll7/p/7569078.html ColorSchemer Studio是一款专业配色软件,网页设计或平面设计师必备工具,和ColorP ...
- Leetcode: Capacity To Ship Packages Within D Days
A conveyor belt has packages that must be shipped from one port to another within D days. The i-th p ...