Got a packet bigger than max_allowed_packet bytes


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:

  1. Login as root. This is what I have:
    root@vps [~]#
  2. Because that is the wrong directory, I do a change directory command:
    root@vps [~]# cd ..
  3. That will then give me:
    root@vps [/]#
  4. My etc directory is there, so I:
    root@vps [/]# cd etc
  5. Pull out the trusty vi editor:
    root@vps [/]# vi my.cnf
  6. You may not exactly have the same information as I have in my my.cnf file, but the principle is the same:
    set-variable = max_connections=500
    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
  7. Between [mysqld] and set-variable = max_connections=500, add:

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.

6 thoughts on “Got a packet bigger than max_allowed_packet bytes”

  1. I dont have root access am using shared server so can I add max_allowed_packet to htaccess file ? but how coz I already it and it’s now work for me please advice thanks.

Leave a Reply

Your email address will not be published. Required fields are marked *