When we first started with M2 development, we ‘assumed’ the development environment would be working as smooth as M1. However, this is not the case. Magento 2 needs more server resources, tweaks, configurations for it to run at decent ‘workable’ condition.
One of the issues we normally suffer from is ‘MYSQL server has gone away’. This is pretty evident when we setup our development workspace in vagrant box and using MYSQL server residing on host machine instead of guest. The fix is based on Mac OS X but can be ported nicely to any linux flavours i.e. Ubuntu.
The fix is to add additional configurations in my.cnf file. As I have MYSQL server installed on my host machine, on Mac OS X not on vagrant, I added the following configurations in /usr/local/mysql-5.7.18-macos10.12-x86_64/support-files/my.cnf:
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
auto_increment_increment = 3
table_open_cache = 250
wait_timeout = 7200
reconnect = 1
max_allowed_packet=4000M
innodb_file_per_table = off
innodb-log-file-size = 2047M
innodb-log-buffer-size = 32M
Now, login to your MYSQL from terminal and add the following configuration:
mysql> SET GLOBAL connect_timeout = 10;
Restart your MYSQL server from terminal
mysql.server stop
mysql.server start
And that should do the job.
Cheers!
Have you verified the use of 4G for max_allowed_packet is available after stop/start? SELECT @@max_allowed_packet would show you what is in use. Last time I looked, the upper limit was 1G.