解决办法:
先查看mac本身安装的shell
cat /etc/shells
javascript
# List of acceptable shells for chpass(1).
# Ftpd will not allow users to connect who are not using
# one of these shells.
/bin/bash
/bin/csh
/bin/dash
/bin/ksh
/bin/sh
/bin/tcsh
/bin/zsh
查看默认shell
javascript
chsh
javascript
# Changing user information for iOSTeam.
# Use "passwd" to change the password.
##
# Open Directory: /Local/Default
##
Shell: /bin/zsh
Full Name: iOSTeam
Office Location:
Office Phone:
Home Phone:
~
默认shell为zsh,说明安装mysql时部署的全局变量bash的效用没生效,需要配置的为
javascript
vi ~/.zshrc
进入后输入如下
javascript
export PATH=${PATH}:/usr/local/mysql/bin
结果如下:
javascript
Last login: Wed Apr 10 01:06:29 on ttys015
(base) jerrychen@JerrydeMacBook-Air ~ % vi ~/.zshrc
export PATH="/Users/jerrychen/学习/bin:$PATH"
export PATH=${PATH}:/usr/local/mysql/bin
export PATH="/Users/jerrychen/学习/Anaconda-1.4.0-MacOSX-x86_64/bin:$PATH"
source ~/.bash_profile
# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/Users/jerrychen/anaconda3/bin/conda' 'shell.zsh' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
eval "$__conda_setup"
else
if [ -f "/Users/jerrychen/anaconda3/etc/profile.d/conda.sh" ]; then
. "/Users/jerrychen/anaconda3/etc/profile.d/conda.sh"
else
export PATH="/Users/jerrychen/anaconda3/bin:$PATH"
fi
fi
unset __conda_setup
# <<< conda initialize <<<
~
"~/.zshrc" 21L, 684B
保存退出后执行
javascript
source ~/.zshrc
退出终端,重新打开后输入mysql -uroot -p
,成功进入