MySQL内存耗尽错误 [英] MySQL memory exhausted error

查看:455
本文介绍了MySQL内存耗尽错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

今天我使用一个简单的Java应用程序将大型数据加载到MySQL DB中,并得到以下错误:

Today I was using a simple Java application to load a large size data into MySQL DB, and got a error below:

java.sql.SQLException:语法错误或来自服务器的访问违规消息:内存耗尽''Q1',2.34652631E10,'000','000',5.0519608E9,5.8128358E9,'000','000',8.2756818E9,2'在第5332行

java.sql.SQLException: Syntax error or access violation message from server: "memory exhausted near ''Q1',2.34652631E10,'000','000',5.0519608E9,5.8128358E9,'000','000',8.2756818E9,2' at line 5332"

我试图修改my.ini文件以增加某些点,但它根本不起作用,实际上文件的大小不是那么大,它只是一个14mb xls文件,几乎没有想法,等待任何建议。感谢你的帮助!

I've tried to modified the my.ini file to increase some point, however it doesn't work at all and actually the size of file is not so large, it's just a 14mb xls file, almost running out of idea, awaiting for any suggestion. Appreciate your help!

推荐答案

(没有你的代码的相关部分我只能猜测,但是我们走了......)

(Without the relevant parts of your code I can only guess, but here we go...)

从错误消息中,我将在黑暗中拍摄并猜测您正在尝试在单个查询中加载所有300,000行,这可能是由在一个字符串中连接一大堆 INSERT 语句。当翻译成SQL语句时,14MB XLS文件可能变得很多,并且你的服务器内存试图解析查询时内存不足。

From the error message, I will take a shot in the dark and guess that you are trying to load all of 300,000 rows in a single query, which is probably produced by concatenating a whole bunch of INSERT statements in a single string. A 14MB XLS file can become a lot bigger when translated into SQL statements and your server runs out of memory trying to parse the query.

To解决此问题(按优先顺序):

To resolve this (in order of preference):

转换您的文件为CSV并使用 LOAD DATA INFILE

Convert your file to CSV and use LOAD DATA INFILE.

使用中等大小的多笔交易,只需几千元 INSERT 每个语句。如果你不能简单地导入文件,这是推荐的选项。

Use multiple transactions of moderate size with only a few thousand INSERT statements each. This is the recommended option if you cannot simply import the file.

使用单个事务 - InnoDB MySQL数据库应该处理这个大小范围内的交易规模

Use a single transaction - InnoDB MySQL databases should handle transaction sizes in this size range.

这篇关于MySQL内存耗尽错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆