Answers.Body: <p>Following up on your <a href="https://craftcms.stackexchange.com/questions/30708/cant-backup-database-failed-with-exit-code-1-wamp-server#comment39203_30708">last comment</a>:</p>
  
  <blockquote>
    <p>So I guess my final question is: how can I either manually create the required file (which is missing) or amend the query?</p>
  </blockquote>
  
  <p>You can completely override Craft's default backup command by specifying it in the <a href="https://docs.craftcms.com/v3/config/config-settings.html#backupcommand" rel="nofollow noreferrer">backupCommand</a> config setting.</p>
  
  <p>Craft will attempt to execute whatever is in there when it goes to perform a backup.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-06-24T19:38:08.497Z
Answers.LastActivityDate: 2019-06-24T19:38:08.497Z
Answers.UserDisplayName: Brad Bell
Body: <p>I'm running Craft 3 on a local windows machine, but every time I try to update certain plugins (or Craft itself) I get a message "Couldn't back up the database. How would you like to proceed".</p>
  
  <p>The logs give the following:</p>
  
  <pre><code>[error][craft\controllers\UpdaterController::actionBackup] Error backing up the database: The shell command "mysqldump ..." failed with exit code 1.
  </code></pre>
  
  <p>(I've removed most of the error code for the actual query, let me know if that would be useful).</p>
  
  <p>I'm aware there are well documented hurdles with mysqldump and localhost, but I've already tried the proposed solutions <a href="https://github.com/craftcms/cms/issues/1369" rel="nofollow noreferrer">here</a>, <a href="https://github.com/craftcms/cms/issues/2364" rel="nofollow noreferrer">here</a> and <a href="https://github.com/craftcms/cms/issues/2874" rel="nofollow noreferrer">here</a>.</p>
  
  <p>The global (not local, though I've tried both) PATH env has been set with the root of my MySQL folder ("C:\wamp64\bin\mysql\mysql5.7.26\bin") and I've restarted my machine, server etc. but still get the same error. I've also confirmed mysqldump is running and available in a normal terminal.</p>
  
  <p>I've also tried the official guide to get MAMP working, tweaked as best I could for Windows (though I'm far from experienced so could have done something wrong) and that did nothing either.</p>
  
  <p>I'm running Windows 10 (if that helps).</p>
  
  <p>Any idea what exit code <strong>1</strong> means?</p>
  
  <p><strong>EDIT:</strong> See the comments below, but I've almost cracked this. My remaining issue is that I can't find any examples of the <strong>my.cnf</strong> file. Doesn't seem to be present on any Craft installs I have access to (though only this one has this issue), which means I can't manually generate it and Craft seems to be failing to do so. Any ideas?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-06-20T12:33:34.723Z
Comments.Text: Try to increase `max_allowed_packet` in your MySQL Config and see if that helps.
Comments.UserDisplayName: Oli
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-06-20T13:19:13.503Z
Comments.Text: Nice idea, but didn't work. Tried increasing to 64MB and 512MB, still getting the same error.
Comments.UserDisplayName: theAdhocracy
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-06-20T20:58:22.680Z
Comments.Text: Are you able to execute `mysqldump` to connect to the same database and make a backup from the command line?
Comments.UserDisplayName: Brad Bell
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-06-21T08:03:18.443Z
Comments.Text: So I can run a normal database backup on the command line using something like:
  
  `mysqldump --databases t_craft --single-transaction --set-gtid-purged=OFF --add-drop-database --triggers --routines --events --user=root --password > partial_database_backup.sql`
  
  However, having just tried using the script from the error log, I get an error due to the inclusion of the "&&" symbol, which is stated to be "not a valid statement seperator in this version". Interesting, will dig into this, but if anyone has any ideas how to change that it would be much appreciated!
Comments.UserDisplayName: theAdhocracy
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-06-21T08:12:54.767Z
Comments.Text: Right, did some Googling and came across [this issue](https://github.com/craftcms/cms/issues/2675); apparently the && error is just when running in Power Shell. I've tried again in cmd and received a different error: **Could not open required defaults file: [filepath]\my.cnf; Fatal error in default handling. Program aborted!**
Comments.UserDisplayName: theAdhocracy
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-06-21T08:22:50.357Z
Comments.Text: _(Sorry for all of the comments, just trying to document in case someone else has this issue in the future)_ Okay I found another [issue](https://github.com/craftcms/cms/issues/3727) explaining that the **my.cnf** file passes the username and password info to mysqldump. I've reran the command without reference to the file and with **--user** and **--password** explicitly defined and it works like a charm. So I guess my final question is: **how can I either manually create the required file (which is missing) or amend the query?**
Comments.UserDisplayName: theAdhocracy
Tags: <database><mysql><back-up>
Title: Can't Backup Database - "Failed with exit code 1" (WAMP Server)
ThreadText: # Can't Backup Database - "Failed with exit code 1" (WAMP Server)
  
  (Asked by: username_0 on 2019-06-20)
  
  I'm running Craft 3 on a local windows machine, but every time I try to update certain plugins (or Craft itself) I get a message "Couldn't back up the database. How would you like to proceed".
  
  The logs give the following:
  
  ```
  [error][craft\controllers\UpdaterController::actionBackup] Error backing up the database: The shell command "mysqldump ..." failed with exit code 1.
  
  ```
  
  (I've removed most of the error code for the actual query, let me know if that would be useful).
  
  I'm aware there are well documented hurdles with mysqldump and localhost, but I've already tried the proposed solutions [here](https://github.com/craftcms/cms/issues/1369), [here](https://github.com/craftcms/cms/issues/2364) and [here](https://github.com/craftcms/cms/issues/2874).
  
  The global (not local, though I've tried both) PATH env has been set with the root of my MySQL folder ("C:\wamp64\bin\mysql\mysql5.7.26\bin") and I've restarted my machine, server etc. but still get the same error. I've also confirmed mysqldump is running and available in a normal terminal.
  
  I've also tried the official guide to get MAMP working, tweaked as best I could for Windows (though I'm far from experienced so could have done something wrong) and that did nothing either.
  
  I'm running Windows 10 (if that helps).
  
  Any idea what exit code **1** means?
  
  **EDIT:** See the comments below, but I've almost cracked this. My remaining issue is that I can't find any examples of the **my.cnf** file. Doesn't seem to be present on any Craft installs I have access to (though only this one has this issue), which means I can't manually generate it and Craft seems to be failing to do so. Any ideas?
  
  **Tags:** database, mysql, back-up
  
  > **Comments:**
  > **username_1**: Try to increase `max_allowed_packet` in your MySQL Config and see if that helps.  
  > **username_0**: Nice idea, but didn't work. Tried increasing to 64MB and 512MB, still getting the same error.  
  > **username_2**: Are you able to execute `mysqldump` to connect to the same database and make a backup from the command line?  
  > **username_0**: So I can run a normal database backup on the command line using something like:  `mysqldump --databases t_craft --single-transaction --set-gtid-purged=OFF --add-drop-database --triggers --routines --events --user=root --password > partial_database_backup.sql`  However, having just tried using the script from the error log, I get an error due to the inclusion of the "&&" symbol, which is stated to be "not a valid statement seperator in this version". Interesting, will dig into this, but if anyone has any ideas how to change that it would be much appreciated!  
  > **username_0**: Right, did some Googling and came across [this issue](https://github.com/craftcms/cms/issues/2675); apparently the && error is just when running in Power Shell. I've tried again in cmd and received a different error: **Could not open required defaults file: [filepath]\my.cnf; Fatal error in default handling. Program aborted!**  
  > **username_0**: _(Sorry for all of the comments, just trying to document in case someone else has this issue in the future)_ Okay I found another [issue](https://github.com/craftcms/cms/issues/3727) explaining that the **my.cnf** file passes the username and password info to mysqldump. I've reran the command without reference to the file and with **--user** and **--password** explicitly defined and it works like a charm. So I guess my final question is: **how can I either manually create the required file (which is missing) or amend the query?**  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2019-06-24. Score: 1 | Accepted answer
  
  Following up on your [last comment](https://craftcms.stackexchange.com/questions/30708/cant-backup-database-failed-with-exit-code-1-wamp-server#comment39203_30708):
  
  > So I guess my final question is: how can I either manually create the required file (which is missing) or amend the query?
  
  You can completely override Craft's default backup command by specifying it in the [backupCommand](https://docs.craftcms.com/v3/config/config-settings.html#backupcommand) config setting.
  
  Craft will attempt to execute whatever is in there when it goes to perform a backup.
  
  
  ---
  
  