官术网_书友最值得收藏!

Mac OS X installation instructions

If you are using the Homebrew package manager, MongoDB can be installed using the following two commands:

    $ brew update
    $ brew install MongoDB
The remainder of this chapter assumes you are not using Homebrew and need to install MongoDB manually. If you are installing MongoDB via Homebrew, you can proceed directly to the Confirming successful MongoDB installation section.

After completing the download, open and extract the contents of the .tgz file. You will want to move the extracted contents to a destination folder, /MongoDB. You can do this either via the finder or the command line, whichever you prefer, as follows:

    $ mkdir -p /MongoDB
    $ cd ~/Downloads
    $ cp -R -n MongoDB-osx-x86_64-2.4.9/ MongoDB 

You will want to ensure that the locations of the MongoDB binaries are configured in your environment path so that you can execute MongoDB and Mongo from any working directory. To do this, edit the .profile file in your home folder (~/) and append the location for MongoDB to it. Your .profile file should look something like the following:

export PATH=~/bin:/some/of/my/stuff:/more/stuff:/MongoDB/bin:$PATH

If you don't have this line or are missing .bash_profile completely, you can create one easily by executing the following command:

    $ touch .bash_profile
    $ [edit] .bash_profile
    export PATH=$PATH:/MongoDB/bin

You will more than likely have a lot more than what I have in the preceding lines of code. The important thing is that you append :/MongoDB/bin before the $PATH at the end. The : is a delimiter between different paths (so it's likely that you will be adding your path to the end of an existing list, but before the trailing $PATH).

Here, mongod refers to the MongoDB server instance that you need to invoke, and mongo refers to the Mongo shell, which will be the console through which you will be interacting with the database.

Next, you need to create a default data folder, which MongoDB will use to store all data documents. From the command line, execute the following:

    $ mkdir -p /data/db
    $ chown `id -u` /data/db

Once the files have been properly extracted to the /MongoDB folder and the data folders created, you can then start the MongoDB database server by executing the following command from the command line:

    $ mongod

This should dump a bunch of log statements while the server starts up, but ultimately ends with:

2017-08-04T10:10:47.853+0530 I NETWORK [thread1] waiting for connections on port 27017

That's it! Your MongoDB server is up and running. You can type Ctrl-C to cancel and shut down the server.

主站蜘蛛池模板: 谢通门县| 大邑县| 凤庆县| 吴堡县| 胶州市| 敖汉旗| 当阳市| 迁西县| 垦利县| 广安市| 华池县| 南阳市| 天柱县| 奇台县| 伊金霍洛旗| 师宗县| 满洲里市| 扶沟县| 同仁县| 兰坪| 饶河县| 天台县| 霍山县| 芦溪县| 奉节县| 察隅县| 许昌县| 溧阳市| 安图县| 准格尔旗| 定南县| 马公市| 宁晋县| 永登县| 县级市| 金塔县| 资兴市| 天津市| 湘潭县| 轮台县| 类乌齐县|