Mac install and start mongodb

1, choose your own version download, the download is complete look into the Finder usr folder to see if there is MongoDB
2, by default we can not see the need to enter the command: shift + command + G input / usr / local folder will be able to enter seen it for
3, configure the environment variables
a, open -e .bash_profile (because I do not have this file so that I want to create a new)

 cd ~/
  Create a .bash_profile file: touch .bash_profile
  Open and edit .bash_profile: open .bash_profile
  Then configure the environment variables: export PATH = / usr / local / mongodb / bin: $ PATH
  Then have a look have not installed successfully enter: mongod -version displays the version number is to configure a success
  which mongod may know the path to install

4. Create a database to store directory / data / db:

mkdir -p /data/db

5. Create a log directory

mkdir log
mongod --dbpath data --logpath log/mongod.log --logappend --fork

6, start

mongod or ./mongod

7, stepped on a pit has been started can not start, and then enter the following command into the bin file

./mongod --dbpath ../data/db/

8, opens a new terminal close mongodb

use admin; // switch administrator
db.shutdownServer();

  

Guess you like

Origin www.cnblogs.com/gfweb/p/12232481.html