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?
mysql ? ?
shareimprove this question
asked Nov 9 '11 at 9:01 ? ?
? ?
Muleskinner ? ? ? ?
3,891123868 ? ? ? ?
A BLOB field is a Binary Large OBject. It's just bits. So yes, you can compress the contents, and it gives other (and hopefully, less) bits you store in the BLOB-field instead. It just changes which data you put in it. You'll have to decompress the BLOB-contents when you need it again, too. ? ? ? ? ? ? ? ? ? ?–?Konerak ? ? ? ? ? ? ? ?Nov 9 '11 at 9:12 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
Change in the my.ini file. Include the single line under [mysqld] in your file
max_allowed_packet=500M
now restart the MySQL service and you are done.
See the documentation for further information.
shareimprove this answer
edited Jan 28 '15 at 14:23 ? ?
answered Nov 9 '11 at 9:04 ? ?
? ?
Manuel ? ? ? ?
5,31242651 ? ? ? ?
43 ? ? ? ? ? ? ? ? ? ? ? ?
Most stuff is easy to find through Google, once you know how and where to find it. Taunting is not needed, but if you could provide a link to the correct location in the MySQL documentation, the user gets to know the official sites and resources and can find it for himself easier the next time. Teach a man to fish... ? ? ? ? ? ? ? ? ? ?–?Konerak ? ? ? ? ? ? ? ?Nov 9 '11 at 9:13 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
Thanks seems to be working even though I had hoped this would be possible without having to modify ini files manually. ? ? ? ? ? ? ? ? ? ?–?Muleskinner ? ? ? ? ? ? ? ?Nov 9 '11 at 9:24 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
Changing the my.ini file is basically the same as chaning the settings in other programs. Here it's just a file from which the program reads the info. ? ? ? ? ? ? ? ? ? ?–?Manuel ? ? ? ? ? ? ? ?Nov 9 '11 at 9:30 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
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 setting for everyone until the server restarts:
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/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
shareimprove this answer
answered Jan 20 '14 at 14:32 ? ?
? ?
naw103 ? ? ? ?
866610 ? ? ? ?
10 ? ? ? ? ? ? ? ? ? ? ? ?
-1 for recommending to ssh as root. Root ssh access must be disabled on a safe server. Use sudo instead. ? ? ? ? ? ? ? ? ? ?–?tamasd ? ? ? ? ? ? ? ?Jun 4 '14 at 8:55 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
this was actually done on CentosOS6 , I of course agree about not using root ssh access though ? ? ? ? ? ? ? ? ? ?–?naw103 ? ? ? ? ? ? ? ?Jun 16 '15 at 0:38 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
add a comment ? ? ? ? ? ? ? ? ? ?
up vote ? ? ? ?14 ? ? ? ?down vote
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:
Win+R(shortcut for 'run'), type services.msc, Enter
You could find an entry like 'MySQL56', right click on it, select properties
You could see sth like "D:/Program Files/MySQL/MySQL Server 5.6/bin\mysqld" --defaults-file="D:\ProgramData\MySQL\MySQL Server 5.6\my.ini" MySQL56
I got this answer from http://bugs.mysql.com/bug.php?id=68516
If getting this error while performing a backup, max_allowed_packet can be set in the my.cnf particularly for mysqldump.
[mysqldump]max_allowed_packet=512M
I kept getting this error while performing a mysqldump and I did not understand because I had this set in my.cnf under the [mysqld] section. Once I figured out I could set it for [mysqldump] and I set the value, my backups completed without issue.