How to set environment variables on Mac OS X
By:Roy.LiuLast updated:2019-08-18
In Mac OS X, you can set the environment variables in one of the following files :
- ~/.bashrc
- ~/.bash_profile
- ~/.profile
By default, Mac OS X does not has above files, you need to create it manually.
$PATH example
This example shows you how to set “mongodb/bin” folder to the existing $PATH environment variable.
$ echo $PATH /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin $ mongo -version -bash: mongo: command not found $cd ~ $pwd /Users/mkyong $touch .bash_profile $vim .bash_profile export MONGO_PATH=~/mongodb export PATH=$PATH:$MONGO_PATH/bin ##restart your terminal $ mongo -version MongoDB shell version: 2.0.7 $ echo $PATH /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/Users/mkyong/mongodb/bin
Done.
From:一号门
Previous:How to install MongoDB on Mac OS X
COMMENTS