mac 命令行下连接到MySQL mysql: command not found

mac下刚刚安装完MySQL后使用命令连接到MySQL

mysql -uroot -p

提示:  -bash: mysql: command not found
使用  /usr/local/mysql-8.0.11-macos10.13-x86_64/bin/mysql -uroot -p

可以连接成功

在终端执行 

export PATH="/usr/local/mysql-8.0.11-macos10.13-x86_64/bin:$PATH"

再次执行

mysql -uroot -p

  输入密码后,连接成功

更改系统文件,下次登录不用再次设置

通过编辑 启动文件 来改PATH,
# vim /etc/profile
在文档最后,添加:
export PATH="/opt/STM/STLinux-2.3/devkit/sh4/bin:$PATH"
保存,退出。
 想立即生效请运行:
#source /etc/profile
不报错则成功。
环境变量更改后,在用户下次登陆时生效

 参考链接:

https://apple.stackexchange.com/questions/287476/the-new-created-terminal-can-not-find-the-file-use-which-in-mac

 

原文地址:https://www.cnblogs.com/ryanzheng/p/9279487.html