Mac 下配置环境变量(Mysql为例)

Mac 下的环境变量配置,不像windows下的那么简单明了

1.Mac 下的环境变量也是分级别的

① 系统级别 /etc/profile 和 /etc/paths 系统启动就会加载

② 用户级别 ~/.bash_profile、 ~/.bash_login、 ~/.profile 和 ~/.bashrc

加载顺序依次是
/etc/profile - - > /etc/paths - - > ~/.bash_profile - - > ~/.profile - - > ~/.bashrc

2. 以配置用户级别的~/.bash_profile为例,进行说明
① 打开终端
Mac 下配置环境变量(Mysql为例)

② 输入命令:touch ~/.bash_profile
Mac 下配置环境变量(Mysql为例)

③ 打开文件:方式有两种
第一种如下
Mac 下配置环境变量(Mysql为例)
配置环境变量
Mac 下配置环境变量(Mysql为例)

第二种打开方式:vim ~/.bash_profile
Mac 下配置环境变量(Mysql为例)
Mac 下配置环境变量(Mysql为例)

我配置的是mysql的路径,查看环境配置是否生效
Mac 下配置环境变量(Mysql为例)