Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mysql server has gone away error during installing migration (laravel)

So I am using my cmd on my laravel folder and I tried to do (php artisan migrate:install). 2 errors came up.

  1. [PDOException] SQLSTATE[HY000] [2006] MySQL server has gone away

  2. [ErrorException] PDO::__construct(): MySQL server has gone away

Can anyone please explain what I did wrong?

like image 505
Mackinley Avatar asked Jan 27 '16 11:01

Mackinley


1 Answers

You have Lost SQL connection to server during query. It is temporally issue. This is because of very low default setting of max_allowed_packet.

Raising max_allowed_packet in my.cnf (under [mysqld]) to 8 or 16M usually fixes it.

[mysqld]
max_allowed_packet=16M

NOTE: This can be set on your server as it's running. You need to restart the MySQL service once you are done.

Use: set global max_allowed_packet=104857600. My value sets it to 100MB.

like image 97
Hassaan Avatar answered Sep 28 '22 00:09

Hassaan