mysql server has gone away error during installing migration (laravel)
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.
For me the problem seemed to be that I assigned the wrong port to my Laravel project's .env
file. Later, when I matched it with the my.cnf
file, it worked.
I'm using Ubuntu 16.04 + nginx + MariaDB + Laravel project.
This is not a Laravel issue, but a general MySQL Issue. Maybe the server is not running. Are you sure you're running MySQL in the background?
Check this link: MySQL Gone Away
Do the following checks in your system:
- The Database Engine is running
- You have created your database
- You have created an user and granted permissions to the database
- You have setup the user and the database in your Laravel's .env file.
After this, try to run the migrations command again, which is:
php artisan migrate
As explained Here
Let us know if that helps :).