Got Error "MySQL server has gone away"? what is the solution for this?

March 30, 2018 1k views
Apache PHP Frameworks MySQL Ubuntu 16.04

I got these 2 error

  1. "Packets out of order. Expected 0 received 45. Packet size=4739923" &
  2. "SQLSTATE[HY000] [2006] MySQL server has gone away" HELP ME Same application working other server but it's not working here, please help me.
3 comments
  • @gdlc

    How are you connecting to the database? Please post the code.

    You can also post the last few lines of mysql error log to help you solving the problem.

  • My PHP is in 167.99.59.63 server and database is in 45.55.34.229 server, and also added
    bind-address = 45.55.34.229

    Connection COde
    'mysql' => [
    'driver' => 'mysql',
    'host' => env('DBHOST', '45.55.34.229'),
    'port' => env('DB
    PORT', '25000'),
    'database' => env('DBDATABASE', 'g#######'),
    'username' => env('DB
    USERNAME', 'g*******'),
    'password' => env('DBPASSWORD', 'm########'),
    'charset' => 'utf8',
    'collation' => 'utf8
    unicode_ci',
    'prefix' => '',
    'strict' => false,
    'engine' => null,
    'timezone' => '+05:30',
    ],
    //DBNAME, USERNAME, PASSWORD hide in this code

    For Error Log, Check this link
    http://167.99.59.63/application/backend/public/

  • Waiting for your valuable suggestion, please suggest me

2 Answers

Your mysql server has probably timed out and might be fixed by checking if the waittimeout mysql variable in your mysql configuration file (my.cnf) is large enough. It could also be caused by an incorrect or a too large packet. You can fix this by increasing the packet size limit maxallowed_packet in my.cnf file. After doing above restart your mysql server.

I already increased maxallowed_packet and restart mysql, but that problem is not solved. Please give any other solution to solve this issue.

Have another answer? Share your knowledge.