I use the PHP script from the CLI to load remote MySQL databases (gzip) and extract them directly to the MacBook MySQL 5.7 server (not MAMP). It works fine, but as a side effect, my PHP applications (MAMP Pro) lose the MySQL connection in the middle of the CLI script with a warning
PHP Warning: mysqli::__construct(): MySQL server has gone away in ...
This happens after a crossroads around dozens of databases (cannot reproduce the exact amount). While the CLI script is being executed, the MySQL panel in System Preferences goes from green / works to red / stopped to work green / start again after each CLI dump that does not conflict with PHP applications in the browser at first. But at some point, PHP applications obviously lose their connection.
I played with my.cnf and installed
[mysqld] max_allowed_packet=128M max_connections=1024
or other amounts, but that doesn’t change anything.
When I manually stop and start MySQL in System Preferences after completing the CLI script, PHP continues to work fine again.
Any ideas?
EDIT:
Thanks, but this has not yet been fixed. So the main idea of the script:
$tmpPath = '/tmp/' For each of 30 databases with different size: $dbName = database name exec('ssh user@server.com "mysqldump --login-path=local --lock-tables=false '.$dbName.' | gzip" > '.$tmpPath.$dbName.'.sql.gz'); exec('gzip -q -dc '.$tmpPath.$dbName.'.sql.gz | mysql -u root -proot '.$dbName)
As I said, the PHP CLI script in the terminal does not complain at all! Its my PHP applications (backend for third-party Angular applications), which somewhere in the middle of 30 dumps stop working due to the mentioned error.
source share