64-bit Linux system installation mongodb
1. Download and install
curl -O https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-3.0.6.tgz # download tar -zxvf mongodb-linux-x86_64-3.0.6.tgz # Unzip mv mongodb-linux-x86_64-3.0.6/ /usr/local/mongodb # Copy the decompressed package to the specified directory m
2. Add the installation directory address to the path path
The MongoDB executable is located in the bin directory, so you can add it to your PATH :
export PATH=<mongodb-install-directory>/bin:$PATH
<mongodb-install-directory> is your MongoDB installation path. Such as /usr/local/mongodb in this article .
export PATH=/usr/locl/mongodb/bin:$PATH ##If your installation directory is /usr/local/mongodb, you can execute this
3. Create the database directory
The data of MongoDB is stored in the db directory of the data directory, but this directory will not be created automatically during the installation process, so you need to manually create the data directory and create the db directory in the data directory.
In the following example, we will create the data directory under the root directory (/).
Note: /data/db is the default start-up database path for MongoDB (--dbpath).
mkdir -p /data/db
4. Start the mongodb service
Execute the mongod command in the bin directory in the installation directory to start the mongodb service
$ ./mongod
After the service starts, open another window, open the bin directory under the mongodb installation directory, and then execute the mongo command file (when you enter the mongoDB background, it will link to the test document (database) by default)
5. MongoDb web user interface
To open the user interface, you need to add the parameter --test when starting the mongodb service.
$ ./mongod --dbpath=/data/db --rest
MongoDB's web interface access port is 1000 more ports than the service's port.
If your MongoDB running port uses the default 27017, you can access the web user interface at the port number 28017, that is, the address is: http://localhost:28017.
That's it!
Note: The default link on the virtual machine linux is 127.0.0.1, and the port is: 27017. Only the ip of the virtual machine can be accessed when the interface is accessed.
http://<ip of the virtual machine>:28017