Prepare the MongoDB Environment

Source: Internet
Author: User

Prepare the MongoDB Environment

1. Install MongoDB

MongoDB installation is very simple. You only need to extract the downloaded MongoDB compressed file to any directory and add the bin directory to the path environment variable of the system.

 

2. Start MongoDB

Before starting MongoDB, you must manually create a directory for storing MongoDB data files, such as D: \ mongo_data.

Run mongod -- dbpath = D: \ mongo_data on the command line.

Tip: manually create a file with the suffix "bat". The file name is arbitrary and the content is mongod -- dbpath = D: \ mongo_data. Double-click the file to start the MongoDB service, you do not need to execute the startup command on the command line every time.
In the shell that starts the server, you can type Ctrl-C to completely stop running mongod.

You can also use the command to install mongodb as a service:
D: \ mongodb \ bin \ mongod.exe -- logpath D: \ mongo_log \ mongodb. log -- logappend -- dbpath D: \ mongo_data -- directoryperdb -- serviceName MongoDB -- install

Remove this service from the System Service: D: \ mongodb \ bin \ mongod.exe -- logpath D: \ mongo_log \ mongodb. log -- logappend -- dbpath D: \ mongo_data -- directoryperdb -- serviceName MongoDB -- remove

 

3. Connect to the MongoDB Server

In the command line, you can use the mongo command to connect to the MongoDB server. Enter the following mongo command to connect to the local database named test by default. If you want to connect to a remote database, you can use the mongo ip: port

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.