title: OSX Sierra /usr/bin/env: ‘mysqldump’: No such file or directory
body: <p>Having issues running a <a href="https://roots.io/leveraging-wp-cli-aliases-in-your-wordpress-development-workflow/" rel="nofollow noreferrer">shell script</a> that invokes mysqdump to import the database. This is for the importing of a WordPress database from production to local dev machine. It worked in the past. But something must have changed on my local MacOs Mac Mini running OSX Sierra.
  This is the script:</p>
  
  <pre><code># sync-prod.sh
  read -r -p "Do you solemnly swear that you have had fewer than 2 alcoholic beverages in the last hour and that you would really like to reset your development database and pull the latest from production? [y/N] " response
  if [[ $response =~ ^([yY][eE][sS]|[yY])$ ]]
  then
      wp @development db reset --yes
      wp @production db export - &gt; sql-dump-production.sql
      wp @development db import sql-dump-production.sql
      wp @development search-replace https://example.com http://example.test
  else
      exit 0
  fi
  </code></pre>
  
  <p>when I run it I get:</p>
  
  <pre><code>./sync-production.sh
  Do you solemnly swear that you have had fewer than 2 alcoholic beverages in the last hour and that you would really like to reset your development database and pull the latest from production? [y/N] y
  Success: Database reset.
  /usr/bin/env: ‘mysqldump’: No such file or directory
  Success: Imported from 'sql-dump-production.sql'.
  Error: The site you have requested is not installed.
  </code></pre>
  
  <p>When I run mysqldump</p>
  
  <pre><code>jasper@~/webdesign/example.com/site $ which mysqldump
  /usr/local/bin/mysqldump
  </code></pre>
  
  <p>from the terminal it starts fine:</p>
  
  <pre><code>$ mysqldump
  Usage: mysqldump [OPTIONS] database [tables]
  OR     mysqldump [OPTIONS] --databases [OPTIONS] DB1 [DB2 DB3...]
  OR     mysqldump [OPTIONS] --all-databases [OPTIONS]
  For more options, use mysqldump --help
  </code></pre>
  
  <p>Read <a href="https://stackoverflow.com/questions/44440064/env-mysql-no-such-file-or-directory-after-wp-import">env: mysql: No such file or directory after `wp import`</a> and tried adjusting the $PATH and now have</p>
  
  <pre><code>echo $PATH
  /usr/local/sbin:/usr/local/mysql/bin:/usr/local/sbin:/usr/local/sbin:/usr/local/sbin:/usr/local/sbin:/Users/jasper/.rvm/gems/ruby-2.3.3/bin:/Users/jasper/.rvm/gems/ruby-2.3.3@global/bin:/Users/jasper/.rvm/rubies/ruby-2.3.3/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/jasper/.composer/vendor/bin:/usr/local/bin:/Users/jasper/.rvm/bin:/Users/jasper/.composer/vendor/bin:/usr/local/bin:/usr/local/mysql/bin:/Users/jasper/.composer/vendor/bin:/usr/local/bin:/usr/local/bin/mysql:/Users/jasper/.composer/vendor/bin:/usr/local/bin:/usr/local/bin/mysql:/Users/jasper/.composer/vendor/bin:/usr/local/bin:/usr/local/bin/mysql:/Users/jasper/.composer/vendor/bin:/usr/local/bin:/usr/local/bin/mysql
  </code></pre>
  
  <p>In .bash_profile I have</p>
  
  <pre><code>alias ll='ls -lGaf'
  export PATH="/usr/local/sbin:$PATH"
  export PATH="$PATH:$HOME/.composer/vendor/bin"
  export PATH=$PATH:/usr/local/bin
  export PATH=$PATH:/usr/local/bin/mysql
  [[ -s "$HOME/.rvm/scripts/rvm" ]] &amp;&amp; source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
  
  ###-tns-completion-start-###
  if [ -f /Users/jasper/.tnsrc ]; then
      source /Users/jasper/.tnsrc
  fi
  ###-tns-completion-end-###
  export PS1="\u@\w $ "
  </code></pre>
  
  <p>When I run <code>wp @production db check</code> things do connect and are fine. I also can connect to the database over ssh using the same username and password using SequelPro..
  Any ideas why I still get no such file or directory for running mysql as part of this script?</p>