Got a packet bigger than max_allowed_packet bytes

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:

  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:
    [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
  7. 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.

Related Posts with Thumbnails You can leave a response, or trackback from your own site.
6 Comments Announcements

Comments

6 Comments so far. You can leave a response, or trackback from your own site.
  1. Thank you
    Great help

  2. any idea how to change this value in MAMP? I can’t find the my.conf file anywhere!

  3. 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 32M

  4. kev,

    edit /Applications/mamp/bin/startMysql.sh and add:
    –max_allowed_packet=32M

  5. Kev: Thanks for the info! I’m sure many people will find this very useful to know.

  6. 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.

Add Your Comments

Required
Required
Tips

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <ol> <ul> <li> <q cite=""> <strike> <strong> <sub> <sup> <u>

Your email is never published nor shared.

Ready?