drush sql-sync error: Lost connection to MySQL server at 'reading initial communication packet'

Mark_L6n's picture

I've got a new Managed VPS, and am trying to get a Drupal site put there with drush rsync and sql-sync. However, I'm getting the following error from drush sql-sync, following the 2nd time you enter a password:
ERROR 2013 (HY000): Lost connection to MySQL server at 'reading initial communication packet', system error: 0

Does anyone know what this could be related to?

The host says 'This error occurs if the database connection to the server fails. It happens due to lacking sufficient permissions for the user from that IP address.' However, they've already granted all privileges to my IP address, and I can use drush to issue a basic SQL command with no errors, as:
drush @alias sql-query "SHOW TABLES"
Drush rsync also works fine.

This doesn't appear related to the problem, but since it occurs I'll mention it: there are issues with permissions for writing files. When I installed Drupal, sites/default/files/ and sites/default/settings.php, couldn't be created by the drupal installation program; after I created them, 755 permissions weren't good enought and I had to give both of them 777 permissions for installation to succeed.


The error turns out to be

Mark_L6n's picture

The error turns out to be caused by not having specified the MySQL port.
The port specified in 'ssh-options' was also being used for the MySQL port; using 'remote-port' to specify the MySQL port solved the problem.