Migration fails: MySQL server has gone away

Created:

2016-12-12 03:47:24 UTC

Modified:

2017-08-16 16:30:01 UTC

1

Was this article helpful?


Have more questions?

Submit a request

Migration fails: MySQL server has gone away

Applicable to:

  • Plesk for Windows
  • Plesk for Linux

Symptoms

  1. Migration fails with the following error in Plesk Migrator debug.log :

    |2016-11-02_00:12:24,282|D|ST1|core.runners.base|example.com||Execute command on the local server:  mysql --defaults-file=/usr/local/psa/var/modules/panel-migrator/sessions/20161029124939/target-server/my_localhost_example.cnf -h localhost -P 3306 -uadmin password < /usr/local/psa/var/modules/panel-migrator/sessions/20161029124939/target-server/db-dumps/my_database.sql
    +|2016-11-02_00:14:36,860|D|ST1|core.runners.base|example.com||Command execution results:
    =|2016-11-02_00:14:36,860|D|ST1|core.runners.base|example.com||stdout:
    =|2016-11-02_00:14:36,860|D|ST1|core.runners.base|example.com||stderr: ERROR 2006 (HY000) at line 1965: MySQL server has gone away
    =|2016-11-02_00:14:36,860|D|ST1|core.runners.base|example.com||
    =|2016-11-02_00:14:36,860|D|ST1|core.runners.base|||exit code: 1
  2. The following error in info.log :

    |- error: Failed to copy content of database 'my_database'
    | Migration tools tried to perform operation in 3 attempts: Command execution failed on the source server 'source' (10.20.30.40) with non-zero exit code.
    | command: MYSQL_PWD="$(cat)" mysqldump -h localhost -P 3306 -uadmin --quick --quote-names --add-drop-table --default-character-set=utf8 --set-charset --routines user > /tmp/db-dumps/my_database.sql
    | exit code: -1

Cause

Database my_database.sql has a filesize > 5GB and it cannot be dumped because of timeout on the source server.

Resolution

  1. Login to the server over SSH/RDP
  2. Increase wait_timeout , max_allowed_packet in MySQL configuration file my.cnf on the source and destination servers, e.g.:

    For Linux:
    /etc/my.cnf:
    wait_timeout = 31536000
    max_allowed_packet=64M
    For Windows:
    "%plesk_dir%"\Databases\MySQL\Data\my.ini
    wait_timeout = 2147483
  3. Restart MySQL server on the source server:

    # service mysql restart
  4. Restart the migration

Have more questions? Submit a request
Please sign in to leave a comment.