tags:

views:

23333

answers:

9

Hi, 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

The dump is a mysqldump of a FogBugz database. it's FogBugz 6.1.33, Unix.

Apparently FogBugz stores attachments in the database, which makes for very large inserts.


This is on my local machine, a Mac with MySQL 5 installed from the MySQL package.

Where do I change max_allowed_packet to be able to import the dump?
Is there anything else I should set?
Just running mysql --max_allowed_packet=32M … resulted in the same error.

A: 

This can be changed in your my.ini file (located in program files, mysql, mysql Server) under the server section, for example:

[mysqld]

max_allowed_packet = 10M

GHad
on a mac, file obviously located elsewhere.
kch
sure, but the configuration is still somewhere although I don't know the exact location
GHad
A: 

Use a max_allowed_packet variable issuing a command like

mysql --max_allowed_packet=32M -u root -p database < dump.sql

Tomasz Tybulewicz
tried that, didn't work. whole dump in 272mb, tried with max higher than that.
kch
A: 

Set max_allowed_packet to the same (or more) than what it was when you dumped it with mysqldump. If you can't do that, make the dump again with a smaller value.

That is, assuming you dumped it with mysqldump. If you used some other tool, you're on your own.

MarkR
did that, didn't work. used mysqldump indeed.
kch
+28  A: 

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

Also, change the my.cnf or my.ini file under the mysqld section and set max_allowed_packet=100M 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.)

Michael Pryor
guess corporate support still beats this community thing :P
kch
+3  A: 

Re my.cnf on Mac OS X when using MySQL from the mysql.com dmg package distribution

By default, my.cnf is nowhere to be found.

You need to copy one of /usr/local/mysql/support-files/my*.cnf to /etc/my.cnf and restart mysqld. (Which you can do in the MySQL preference pane if you installed it.)

kch
+6  A: 

As michaelpryor said, you have to change it for both the client and the daemon mysqld server.

His solution for the client command-line is good, but the ini files don't always do the trick, depending on configuration.

So, open a terminal, type mysql to get a mysql prompt, and issue these commands:

set global net_buffer_length=1000000; 
set global max_allowed_packet=1000000000;

Keep the mysql prompt open, and run your command-line SQL execution on a second terminal..

Joshua Fox
Solved the problem for me; the import I'm doing is a once-off, and I can't easily change the configuration. This worked great. :D
Rob Howard
Perfect solution - needed it only for 1-time import!
Leonti
+1  A: 

Slightly unrelated to your problem, so here's one for Google.

If you didn't mysqldump the SQL, it might be that your SQL is broken.

I just got this error by accidentally having an unclosed string literal in my code. Sloppy fingers happen.

That's a fantastic error message to get for a runaway string, thanks for that MySQL!

jplindstrom
A: 

Thanks a lot , it worked for me when it wanted and exactly how it was planned

jaldip
A: 

If you dont have root acces you can try reducing the commit each data block margin...

ata