How to set environment variables on Mac OS X

摘要: In Mac OS X, you can set the environment variables in one of the following files :

In Mac OS X, you can set the environment variables in one of the following files :

  1. ~/.bashrc
  2. ~/.bash_profile
  3. ~/.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.

上一篇: How to install MongoDB on Mac OS X
下一篇: Maven, JAVA_HOME is not defined correctly on Mac OSX
 评论 ( What Do You Think )
名称
邮箱
网址
评论
验证
   
 

 


  • 微信公众号

  • 我的微信

站点声明:

1、一号门博客CMS,由Python, MySQL, Nginx, Wsgi 强力驱动

2、部分文章或者资源来源于互联网, 有时候很难判断是否侵权, 若有侵权, 请联系邮箱:summer@yihaomen.com, 同时欢迎大家注册用户,主动发布无版权争议的 文章/资源.

3、鄂ICP备14001754号-3, 鄂公网安备 42280202422812号