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.
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.
The fix is to increase the MySQL daemon’s max_allowed_packet. You can do this to a running daemon by logging in as Super and running the following commands.
Then to import your dump:
Sometimes type setting:
in my.ini is not working.
Try to determine the my.ini as follows:
or
Then restart the server:
In etc/my.cnf try changing the max_allowed _packet and net_buffer_length to
if this is not working then try changing to
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:
Keep the mysql prompt open, and run your command-line SQL execution on a second terminal..
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.
On CENTOS 6 /etc/my.cnf , under [mysqld] section the correct syntax is: