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
One of my junior developers was having a problem modifying this for me so I thought I would expand this in greater detail for linux users:
1) open terminal
2) ssh root@YOURIP
3) enter root password
4) nano /etc/mysql/my.cnf (if command is not recognized do this first or try vi then repeat: yum install nano )
5) add the line: max_allowed_packet=256M (obviously adjust size for whatever you need) under the [MYSQLD] section. He made a mistake of putting it at the bottom of the file first so it did not work.
6) Control + O (save) then ENTER (confirm) then Control + X (exit file)
7) service mysqld restart
8) You can check the change in the variables section on phpmyadmin
For those running wamp mysql server
Wamp tray Icon -> MySql -> my.ini
[wampmysqld]
port = 3306
socket = /tmp/mysql.sock
key_buffer_size = 16M
max_allowed_packet = 16M // --> changing this wont solve
sort_buffer_size = 512K
Scroll down to the end until u find
[mysqld]
port=3306
explicit_defaults_for_timestamp = TRUE
Add the line of packet_size in between
[mysqld]
port=3306
max_allowed_packet = 16M
explicit_defaults_for_timestamp = TRUE
Check whether it worked with this query
Select @@global.max_allowed_packet;
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.
I think some would also want to know how to find the my.ini file on your PC. For windows users, I think the best way is as follows:
I got this answer from http://bugs.mysql.com/bug.php?id=68516
set global max_allowed_packet=10000000000;
The max_allowed_packet variable can be set globally by running a query.
However, if you do not change it in the my.ini
file (as dragon112 suggested), the value will reset when the server restarts, even if you set it globally.
To change the max allowed packet for everyone to 1GB until the server restarts:
SET GLOBAL max_allowed_packet=1073741824;