In WINDOWS:

A, install,

Step 1: Download MongoDB \

The url to download address: downloads.mongodb.org/win32/

\

Step 2: Set the MongoDB directory

For example, unpack it to c:\ and rename it mongo to c:\mongo.

\

Step 3: Set the directory for storing data files

For example, create a DB folder on disk C: with path C :\db

\

Step 4: Start the MongoDB service

Go to the CMD prompt console, c:\mongo\bin\mongod. Exe –dbpath=c:\db.

You can write c:\mongo\bin\ to the environment variable instead of writing this path every time.

— DBpath is a parameter.

You can use mongod /? Or mongod –help to view the other parameters. Such as

–logpath Log directory

–journal Indicates the start of application logs.

— RepairPath repair (specify the directory name because we installed into the default directory data\ DB)

For Windows parameters

Install Is installed as a service

Remove Uninstall the service.

The repair or repairPath parameter is used in the event that mongodb fails to start next time due to unexpected reasons, such as downtime. It is said that when using the journal parameter at startup, it will be more precise to avoid this defect.

\

Step 5. Connect

Open a CMD: c:\mongo\bin\mongo to start the MongoDB tour

\

Step 6 disconnect

Once connected to mongoDB, to disconnect, type Exit or CTRL + C

\

Step 7 close the database

To connect, use admin, switch to admin, and then type db.shutdownServer().

\

Add: If you want to start MongoDB immediately after startup, you can randomly start MongoDB as a Windows service. First create C:\mongo\logs\ MongoDB. Log file to store MongoDB log files, and then install system services. \

C:\mongo\bin\mongod  –dbpath=c:\ db –logpath=c:\mongo\lo gs\mongodb.log –journal –install \

To uninstall, replace Install with remove

= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =

If MongoDB has been installed as a WINDOWS service, for some reason,

Either in the mongodb service, enter

>use admin

>db.shutdownServer()

Again, in WINDOWS CMD, type

net stop MongoDB

Can stop the service, but at the same time will report an error.

\