Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Detailed explanation of MongoDB4.0 installation and service configuration tutorial under windows10

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Local installation and web testing

1. Download the latest installation files on the official website

Download address: https://www.mongodb.com/download-center#community

You can choose the Community Server version to download from MongoDB's official website, but it often doesn't seem to respond. You can choose the version you want to download directly here, and you can directly select the msi installation file to install it under Windows.

Install msi files

After downloading, agree to next, and select the custom option in the middle step to select your preferred installation location.

Modify the installation path.

There is something wrong with this MSI file. It must not be changed here. Just next it directly, otherwise it will not work even if you change it back.

Uncheck here and do not install graphical tools, otherwise it will take a very long time.

The installation comes to an end.

The file directory after installation is as follows

MongoDB has just been installed under E:\ Program Files\ MongoDB\ Server\ 4.0\, which is called the installation directory\.

Configure and turn on from the alternate path (but not do it)

1. Create a db directory under the installation directory\ data\ as an alternate directory for the installation directory\ data\, and create a new file mongo.config (installation directory\ log\ mongo.config) under the log folder

When starting, you use the mongod.exe under the installation directory\ bin\. If you start it directly, you actually use C:\ data\ db\ to store the directory for the database files, and you need to make sure that the directory exists.

You can use-- dbpath "installation directory\ data\ db" to explicitly specify this directory as the storage location to start MongoDB, such as:

E:\ Program Files\ MongoDB\ Server\ 4.0\ bin >

Mongod.exe-- dbpath "E:\ Program Files\ MongoDB\ Server\ 4.0\ data\ db"

two。 Partial output:

Now that MongoDB is open, the browser accesses http://localhost:27017/ and the output on the page is:

It looks like you are trying to access MongoDB over HTTP on the native driver port.

3. Indicates that MongoDB has been started and its default port (27017) is not occupied.

Test use

Keep MongoDB open, and use the mongo.exe in the installation directory\ bin\ to start the operating terminal of MongoDB:

Test:

> db

Test

> show dbs

Admin 0.000GB

Config 0.000GB

Local 0.000GB

>

Check the local MongoDB service

Because it was checked during installation, this service should be available, as you can see in services.msc:

If not, you can refer to here for configuration.

Turn off and enable the MongoDB service

Turning off the echo interface just now does not close MongoDB, because it is ensured that it is in the service, so you can use the net command to control whether it is turned on or off.

Turn off the MongoDB service with net stop "MongoDB Server":

The MongoDB Server service is stopping.

The MongoDB Server service stopped successfully.

4. Open the MongoDB service with net start MongoDB Server:

The MongoDB Server service is starting..

The MongoDB Server service has started successfully.

Configure as a windows service

1. Open the command line as an administrator, cd to the bin folder in the installation directory, and execute the following command: mongod-dbpath E:\ MongoDB\ data\ db-logpath E:\ MongoDB\ log\ mongo.log-logappend-serviceName MongoDB-auth-install. Where the database path is E:\ MongoDB\ data\ db, the log path is E:\ MongoDB\ log\ mongo.log, and the service name is MongoDB.

two。 If successful, cmd will be prompted that the service has been installed successfully. You can also view it in the list of services in the Task Manager. Run cmd to execute directly: net start MongoDB, indicating that the service starts successfully. Net stop MongoDB is used to shut down the service.

3. Possible mistakes:

(1.) It is suggested that the error caused by "the service does not respond to control" is due to the wrong input in the first step of configuration. Use the sc delete MongoDB command in cmd to remove the previously installed service and reperform the first step to make sure it is accurate.

(2.) Report an error "access denied"

2016-11-01T20:52:21.647+0800 I CONTROL [main] Trying to install Windows service 'MongoDB'

2016-11-01T20:52:21.648+0800 I CONTROL [main] Error connecting to the Service Control Manager: access denied. (5)

Reason: you should run cmd as an administrator

Find the command processor C:\ Windows\ System32\ cmd.exe

Right-click: run as administrator

Summary

The above is the detailed explanation of the installation and service configuration tutorial of MongoDB4.0 under windows10 introduced by the editor. I hope it will be helpful to you. If you have any questions, you are welcome to leave a message. The editor will reply you in time!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report