Introduction
Recently I was getting this error: WordPress database error: [Got a packet bigger than 'max_allowed_packet' bytes] every time I was making a new post, editing an existing post, making a new page, or editing an existing page. I was hoping nothing was messed with my WordPress database, fortunately this message doesn’t mean anything is wrong with the database.
How Do I Fix It?
The answer to this question depends. If you have a virtual private server (VPS) or root access to MySQL, it’s an easy 5 minute fix. If you don’t have a VPS, don’t know how to do it, or don’t have root access, you’re web host will have to fix it for you.
For those who do have access, here’s what you do:
- Login as root. This is what I have:
root@vps [~]#
- Because that is the wrong directory, I do a change directory command:
root@vps [~]# cd ..
- That will then give me:
root@vps [/]#
- My etc directory is there, so I:
root@vps [/]# cd etc
- Pull out the trusty vi editor:
root@vps [/]# vi my.cnf
- You may not exactly have the same information as I have in my my.cnf file, but the principle is the same:
[mysqld] set-variable = max_connections=500 safe-show-database set-variable = key_buffer_size=3M set-variable = table_cache=132 set-variable = read_buffer_size=2M set-variable = join_buffer_size=2M set-variable = sort_buffer_size=2me: vps.bui4ever.com2007 set-variable = read_rnd_buffer_size=2M set-variable = query_cache_size=64M set-variable = query_cache_limit=4Mold-passwords = 1
- Between [mysqld] and set-variable = max_connections=500, add:
max_allowed_packet=16M
In many cases, that will resolve the issue. Worse case scenario, you’ll have to increase it to as high as 32MB. It’s not a good idea to set it to high as it will utilize more server resources and also cause other errors. For more reading, go to MySQL Reference Manual B.1.2.9 Packet too large.
Popularity: 13% [?]
If you liked this post then consider subscribing to our full feed RSS. You could also subscribe to our email feed and have new posts sent directly to your inbox.
Thank you
Great help
any idea how to change this value in MAMP? I can’t find the my.conf file anywhere!
I use MAMP, but I’m not 100% sure where to find it. Have you tried adding this to your .htaccess file to see if it works:
php_value memory_limit 32Medit /Applications/mamp/bin/startMysql.sh and add:
–max_allowed_packet=32M
Kev: Thanks for the info! I’m sure many people will find this very useful to know.