MySQL Error 1153 - Got a packet bigger than #39;max_allowed_packet#39; bytes(MySQL 错误 1153 - 数据包大于“max_allowed_packet字节)
问题描述
我正在导入 MySQL 转储并收到以下错误.
I'm importing a MySQL dump and getting the following error.
$ mysql foo < foo.sql
ERROR 1153 (08S01) at line 96: Got a packet bigger than 'max_allowed_packet' bytes
显然数据库中有附件,这使得插入非常大.
Apparently there are attachments in the database, which makes for very large inserts.
这是在我的本地机器上,一台从 MySQL 包安装了 MySQL 5 的 Mac.
This is on my local machine, a Mac with MySQL 5 installed from the MySQL package.
我在哪里更改 max_allowed_packet
以便能够导入转储?
Where do I change max_allowed_packet
to be able to import the dump?
还有什么我应该设置的吗?
Is there anything else I should set?
只是运行 mysql --max_allowed_packet=32M ...
导致同样的错误.
Just running mysql --max_allowed_packet=32M …
resulted in the same error.
推荐答案
您可能必须为客户端(您正在运行以执行导入)和正在运行并接受导入的守护进程 mysqld 更改它.
You probably have to change it for both the client (you are running to do the import) AND the daemon mysqld that is running and accepting the import.
>
对于客户端,可以在命令行指定:
For the client, you can specify it on the command line:
mysql --max_allowed_packet=100M -u root -p database < dump.sql
另外,更改mysqld部分下的my.cnf或my.ini文件(通常在/etc/mysql/中)并设置:
Also, change the my.cnf or my.ini file (usually found in /etc/mysql/) under the mysqld section and set:
max_allowed_packet=100M
或者您可以在连接到同一服务器的 MySQL 控制台中运行这些命令:
or you could run these commands in a MySQL console connected to that same server:
set global net_buffer_length=1000000;
set global max_allowed_packet=1000000000;
(使用非常大的数据包大小值.)
(Use a very large value for the packet size.)
这篇关于MySQL 错误 1153 - 数据包大于“max_allowed_packet"字节的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:MySQL 错误 1153 - 数据包大于“max_allowed_packet"字节


基础教程推荐
- 使用pyodbc“不安全"的Python多处理和数据库访问? 2022-01-01
- ERROR 2006 (HY000): MySQL 服务器已经消失 2021-01-01
- SQL Server 中单行 MERGE/upsert 的语法 2021-01-01
- 如何在 SQL Server 的嵌套过程中处理事务? 2021-01-01
- SQL Server 2016更改对象所有者 2022-01-01
- Sql Server 字符串到日期的转换 2021-01-01
- 在 VB.NET 中更新 SQL Server DateTime 列 2021-01-01
- SQL Server:只有 GROUP BY 中的最后一个条目 2021-01-01
- 无法在 ubuntu 中启动 mysql 服务器 2021-01-01
- 将数据从 MS SQL 迁移到 PostgreSQL? 2022-01-01