Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change max_allowed_packet size

Tags:

mysql

I am having a problem with BLOB fields in my MySQL database - when uploading files larger than approx 1MB I get an error Packets larger than max_allowed_packet are not allowed.

Here is what i've tried:

In MySQL Query Browser I ran a show variables like 'max_allowed_packet' which gave me 1048576.

Then I execute the query set global max_allowed_packet=33554432 followed by show variables like 'max_allowed_packet' - it gives me 33554432 as expected.

But when I restart the MySQL server it magically goes back to 1048576. What am I doing wrong here?

Bonus question, is it possible to compress a BLOB field?

like image 886
Muleskinner Avatar asked Nov 09 '11 09:11

Muleskinner


People also ask

What is max allowed packet size?

The largest possible packet that can be transmitted to or from a MySQL 8.0 server or client is 1GB. When a MySQL client or the mysqld server receives a packet bigger than max_allowed_packet bytes, it issues an ER_NET_PACKET_TOO_LARGE error and closes the connection.

Where can I find max_allowed_packet?

You have two values of max_allowed_packet in MySQL : one on the client side : [mysql] section, [mysqldump] , [client] and more. one on the server side : [mysqld] section.

What is max_allowed_packet MariaDB?

How does max_allowed_packet Function Work in MariaDB? Maximum size of max_allowed_packet is in bytes or it generates the intermediate string. In which we can set the packet message buffer value from the net_buffer_length but we can increase that value by using the max_allowed_packet bytes.

Could not run MySQL server has gone away?

The most common reason for the MySQL server has gone away error is that the server timed out and closed the connection. In this case, you normally get one of the following error codes (which one you get is operating system-dependent). The client couldn't send a question to the server.


1 Answers

Change in the my.ini or ~/.my.cnf file by including the single line under [mysqld] or [client] section in your file:

max_allowed_packet=500M 

then restart the MySQL service and you are done.

See the documentation for further information.

like image 122
Manuel Avatar answered Sep 20 '22 14:09

Manuel