OSX Sierra /usr/bin/env: 'mysqldump': 没有那个文件或目录

OSX Sierra /usr/bin/env: ‘mysqldump’: No such file or directory

在调用 mysqdump 导入数据库的 shell script 中遇到问题 运行。这是为了将 WordPress 数据库从生产环境导入到本地开发机器。它在过去有效。但是我的本地 MacOs Mac Mini 运行ning OSX Sierra 一定发生了一些变化。 这是脚本:

# 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 - > 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

当我 运行 我得到:

./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.

当我运行mysql转储

jasper@~/webdesign/example.com/site $ which mysqldump
/usr/local/bin/mysqldump

从终端启动正常:

$ 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

阅读 env: mysql: No such file or directory after `wp import` 并尝试调整 $PATH,现在

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

在.bash_profile我有

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" ]] && 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 $ "

当我 运行 wp @production db check 事情确实连接并且很好。我还可以使用 SequelPro 使用相同的用户名和密码通过 ssh 连接到数据库。 任何想法为什么我仍然没有得到 运行ning mysql 这样的文件或目录作为此脚本的一部分?

当您在 shell 中 运行 env mysqldump 命令时会发生什么?例如,您可以安装和使用 strace 和 运行 脚本,或者只是失败的命令,如 strace -F <command>。也许您会透露有关此错误的更多详细信息。

远程服务器确实(不再)安装了 mysql-客户端。一旦我做了 apt install mariadb-client-10 事情又开始工作了:

wp @production db export sql-dump-production.sql
Success: Exported to 'sql-dump-production.sql'.

我也可以 运行:

./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.
Success: Imported from 'sql-dump-production.sql'.
.........