Craft 3 cannot find mysqldump command, console works 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 &gt; Database &gt; 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*
After a lot of digging I found an SO post 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?