Answers.Body: <p>After a lot of digging I found an <a href="https://stackoverflow.com/questions/3431858/php-system-calls-and-path-in-os-x">SO post</a> which recommended updating the environment variable via PHP:</p>
  
  <pre><code>putenv("PATH={$_SERVER["PATH"]}:/usr/local/mysql/bin");
  </code></pre>
  
  <p>Adding that line into <code>craft/config/general.php</code> before the return statement did the trick for me. Craft does back up and Feed Me runs the feed successfully.</p>
  
  <p>BUT: Is that a good solution?</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-06-23T21:57:21.537Z
Answers.Text: Works for me with Valet. Having installed MySQL with Home Brew my path was '/usr/local/Cellar/mysql@5.6/5.6.43/bin'
Answers.UserDisplayName: PhilR
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-07-18T11:35:43.510Z
Answers.LastActivityDate: 2018-07-18T11:35:43.510Z
Answers.UserDisplayName: Crafty Cat
Answers.Body: <p>If you are having this problem using MAMP, Craft has a guide that shows the recommended way to deal with this, which is to use the backupCommand and restoreCommand configuration parameters to specify the mysqldump that MAMP is bundled with.</p>
  
  <p>It also says:</p>
  
  <blockquote>
    <p>We recommend putting them in your .env file so they don't need to be shared in other environments such as production, staging, or your teammates' computers.</p>
  </blockquote>
  
  <p>So add the following to you .env. This assumes your password is "root", change -proot to -pyourpassword if that's not the case.</p>
  
  <pre><code>BACKUP_COMMAND="/Applications/MAMP/Library/bin/mysqldump -h localhost -u root -proot --add-drop-table --comments --create-options --dump-date --no-autocommit --routines --set-charset --triggers --single-transaction --no-data --result-file=\"{file}\" {database} &amp;&amp; /Applications/MAMP/Library/bin/mysqldump -h localhost -u root -proot --add-drop-table --comments --create-options --dump-date --no-autocommit --routines --set-charset --triggers --no-create-info --ignore-table={database}.assetindexdata --ignore-table={database}.assettransformindex --ignore-table={database}.cache --ignore-table={database}.sessions --ignore-table={database}.templatecaches --ignore-table={database}.templatecachecriteria --ignore-table={database}.templatecacheelements {database} &gt;&gt; \"{file}\""
  
  RESTORE_COMMAND="/Applications/MAMP/Library/bin/mysql -h localhost -u root -proot {database} &lt; \"{file}\""
  </code></pre>
  
  <p>And add the backupCommand and restoreCommand configs to your config/general.php</p>
  
  <pre><code>// Dev environment settings
      'dev' =&gt; [
          // existing settings ...
          'backupCommand' =&gt; getenv('BACKUP_COMMAND'),
          'restoreCommand' =&gt; getenv('RESTORE_COMMAND'),
      ],
  </code></pre>
  
  <p>Source: <a href="https://craftcms.com/guides/database-backups-in-craft-3-with-mamp" rel="nofollow noreferrer">https://craftcms.com/guides/database-backups-in-craft-3-with-mamp</a></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-07-01T14:22:13.067Z
Answers.LastActivityDate: 2019-07-01T14:22:13.067Z
Answers.UserDisplayName: Arnolio
Answers.Body: <p>Very nice, for Valet Plus I changed the path to:</p>
  
  <p><code>putenv("PATH={$_SERVER["PATH"]}:/usr/local/opt/mysql@5.7/bin");</code></p>
  
  <p>this does this trick for local backups, I disabled it before pushing config back to production.  </p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-04-24T01:57:58.690Z
Answers.LastActivityDate: 2019-04-24T01:57:58.690Z
Answers.UserDisplayName: Will
Body: <p>I want to use Feed Me with Craft to import my old database, but neither Feed Me nor Craft can find <code>mysqldump</code>.</p>
  
  <p>I know this is a known problem, and I have successfully added the path to <code>$PATH</code> and verified that this is set in my <code>.bash_profile</code>.</p>
  
  <p>When I execute <code>mysqldump</code> on the console I get the familiar usage hints. Executing <code>which mysqldump</code> gives me <code>/usr/local/mysql/bin/mysqldump</code>.</p>
  
  <p>Yet when I go to <code>Craft &gt; Database &gt; Backup</code> it fails. In <code>web.log</code> I find:</p>
  
  <blockquote>
    <p>2018-07-18 21:01:10 [::1][1][-][error][yii\base\Exception] yii\base\Exception: Could not create backup: The shell command "mysqldump --defaults-extra-file="/Users/xxx/mysite.com/code/craft/storage/runtime/temp/my.cnf" 
    [snip]
    _180718_110110_rig2b5xl4z_v3.0.15.sql"" failed with exit code 127: sh: mysqldump: command not found in /Users/xxx/mysite.com/code/craft/vendor/craftcms/cms/src/controllers/UtilitiesController.php:383</p>
  </blockquote>
  
  <p>Why can I run the command in the terminal but Craft cannot? I've checked the permissions, and they should be ok:</p>
  
  <p><code>-rwxr-xr-x   1 root  wheel   4062128 29 Sep  2016 mysqldump*</code></p>
  
Tags: <database>
Title: Craft 3 cannot find mysqldump command, console works
ThreadText: # Craft 3 cannot find mysqldump command, console works
  
  (Asked by: username_0 on 2018-07-18)
  
  I want to use Feed Me with Craft to import my old database, but neither Feed Me nor Craft can find `mysqldump`.
  
  I know this is a known problem, and I have successfully added the path to `$PATH` and verified that this is set in my `.bash_profile`.
  
  When I execute `mysqldump` on the console I get the familiar usage hints. Executing `which mysqldump` gives me `/usr/local/mysql/bin/mysqldump`.
  
  Yet when I go to `Craft > Database > Backup` it fails. In `web.log` I find:
  
  > 2018-07-18 21:01:10 [::1][1][-][error][yii\base\Exception] yii\base\Exception: Could not create backup: The shell command "mysqldump --defaults-extra-file="/Users/xxx/mysite.com/code/craft/storage/runtime/temp/my.cnf"
  > [snip]
  > \_180718\_110110\_rig2b5xl4z\_v3.0.15.sql"" failed with exit code 127: sh: mysqldump: command not found in /Users/xxx/mysite.com/code/craft/vendor/craftcms/cms/src/controllers/UtilitiesController.php:383
  
  Why can I run the command in the terminal but Craft cannot? I've checked the permissions, and they should be ok:
  
  `-rwxr-xr-x 1 root wheel 4062128 29 Sep 2016 mysqldump*`
  
  **Tags:** database
  
  
  ---
  
  ## 3 answers
  
  ### Answer by username_0 on 2018-07-18. Score: 6
  
  After a lot of digging I found an [SO post](https://stackoverflow.com/questions/3431858/php-system-calls-and-path-in-os-x) which recommended updating the environment variable via PHP:
  
  ```
  putenv("PATH={$_SERVER["PATH"]}:/usr/local/mysql/bin");
  
  ```
  
  Adding that line into `craft/config/general.php` before the return statement did the trick for me. Craft does back up and Feed Me runs the feed successfully.
  
  BUT: Is that a good solution?
  
  > **Comments:**
  > **username_1**: Works for me with Valet. Having installed MySQL with Home Brew my path was '/usr/local/Cellar/mysql@5.6/5.6.43/bin'  
  
  ---
  
  ### Answer by username_2 on 2019-07-01. Score: 3
  
  If you are having this problem using MAMP, Craft has a guide that shows the recommended way to deal with this, which is to use the backupCommand and restoreCommand configuration parameters to specify the mysqldump that MAMP is bundled with.
  
  It also says:
  
  > We recommend putting them in your .env file so they don't need to be shared in other environments such as production, staging, or your teammates' computers.
  
  So add the following to you .env. This assumes your password is "root", change -proot to -pyourpassword if that's not the case.
  
  ```
  BACKUP_COMMAND="/Applications/MAMP/Library/bin/mysqldump -h localhost -u root -proot --add-drop-table --comments --create-options --dump-date --no-autocommit --routines --set-charset --triggers --single-transaction --no-data --result-file=\"{file}\" {database} && /Applications/MAMP/Library/bin/mysqldump -h localhost -u root -proot --add-drop-table --comments --create-options --dump-date --no-autocommit --routines --set-charset --triggers --no-create-info --ignore-table={database}.assetindexdata --ignore-table={database}.assettransformindex --ignore-table={database}.cache --ignore-table={database}.sessions --ignore-table={database}.templatecaches --ignore-table={database}.templatecachecriteria --ignore-table={database}.templatecacheelements {database} >> \"{file}\""
  
  RESTORE_COMMAND="/Applications/MAMP/Library/bin/mysql -h localhost -u root -proot {database} < \"{file}\""
  
  ```
  
  And add the backupCommand and restoreCommand configs to your config/general.php
  
  ```
  // Dev environment settings
      'dev' => [
          // existing settings ...
          'backupCommand' => getenv('BACKUP_COMMAND'),
          'restoreCommand' => getenv('RESTORE_COMMAND'),
      ],
  
  ```
  
  Source: <https://craftcms.com/guides/database-backups-in-craft-3-with-mamp>
  
  
  ---
  
  ### Answer by username_3 on 2019-04-24. Score: 1
  
  Very nice, for Valet Plus I changed the path to:
  
  `putenv("PATH={$_SERVER["PATH"]}:/usr/local/opt/mysql@5.7/bin");`
  
  this does this trick for local backups, I disabled it before pushing config back to production.
  
  
  ---
  
  