解决方法来自
http://superuser.com/questions/573633/bash-profile-not-sourced
解决command not found
如使用iterm2 + oh my zsh时
~ mysql
zsh: command not found: mysql
是因为未设置环境变量
参见http://yijiebuyi.com/blog/41ee3bab0c5bf1d43c7a8ccc7f0fe44e.html
比较安全灵活的方法就是~/.bash_profile 或者~/.zshrc或者 ~/.bashrc里添加环境:
# mysql
alias mysql='/usr/local/mysql/bin/mysql'
alias mysqladmin='/usr/local/mysql/bin/mysqladmin'
因为我是用的 oh my zsh 不会自动加载~/.bash_profile
而是~/.zshrc
,其它可能是加载~/.bashrc
等
==下面这个方法有问题,可以参考==
三方终端自动加载.bash_profile
但是有些童鞋使用第三方terminal 时会发现问题依旧,那是因为部分第三方ternimal不会自动加载 .bash_profile文件,导致 需要手动加载:source ~/.bash_profile
方法:
Terminal -> Preferences -> Startup 选项卡, 在 “Shell Opens With:” 把 “Default login shell” 改为 Command 再 填写:
source ~/.bash_profile
==PS:自己创建的~/.bash_profile 重启后会消失,所以第二个方式可能有问题,希望大神不吝赐教。==