Error when upgrading civicrm for wordpress with wp-cli
In order to upgrade CiviCRM for WordPress from the command line on a remote server, I just installed wp-cli following the instructions at https://wp-cli.org/.
When I execute:
wp civicrm upgrade --zipfile ../Downloads/civicrm-5.48.0-wordpress.zip
I get a warning and an error:
Warning: file_get_contents(/home/myhome/www/wp-content/plugins/civicrm/wp-cli//civicrm.settings.php): failed to open stream: No such file or directory in /home/myhome/www/wp-content/plugins/civicrm/wp-cli/civicrm.php on line 946
The upgrade process involves -
1. Backing up current CiviCRM code as => /home/myhome/www/../backup/plugins/20220412055134/civicrm
2. Backing up database as => /home/myhome/www/../backup/plugins/20220412055134/civicrm.sql
3. Unpacking tarfile to => /home/myhome/www/wp-content/plugins/
4. Executing civicrm/upgrade?reset=1 just as a browser would.
Do you really want to continue? [y/n] y
Success: 1. Code backed up.
mysqldump: Got error: 2002: "Can't connect to MySQL server on 'myftpuser-001.privatesql' (115)" when trying to connect
I have been told this happens because the configuration file necessary to access the database is no more there when you try to backup the database.
If that is true, a possible solution would be to change the order of the operations: first backup the database, and then backup the code.