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

How to build MongoDB environment

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

Share

Shulou(Shulou.com)05/31 Report--

How to build MongoDB environment, many novices are not very clear about this, in order to help you solve this problem, the following small series will explain in detail for everyone, there are people who need this can learn, I hope you can gain something.

Download the installation package from MongoDB's official website:

I installed mongoDB in the MyApp directory of drive C. After installation, there are several execution files in bin. Add the bin file path to the windows environment variable.

Start the MongoDB server using the following command line:

mongod --dbpath C:MyAppmongoDBjerryserverdb

Mongo DB starting: pid=16588 port=27017

This means that a process with process id 16588 starts MongoDB and listens on port 27017.

There are other helpful hints in the console, such as:

Read and write access to data and configuration is unrestricted â € "No permissions to read and write data

WARNING: This server is bound to localhost -This server is accessed via localhost

In cmd use the command netstat -ano| find "27017", found that the process id 16588 is indeed listening on port 27017:

Open MongoDB Compass, which is the MongoDB GUI graphical user interface and is automatically installed during MongboDB installation.

Hostname enter localhost, port enter 27017, click Connect to connect:

After connecting, create a new Collection under the admin database:

In my example, the name of collection is person, click INSERT DOCUMENT to create a record, _id is automatically generated by MongoDB compass, and the name of another field is name, and the value is "Jerry":

Click INSERT DOCUMENT again to generate two person records.

Now we open another command prompt window to consume the two person records created in MongoDB Compass.

The command line mongo localhost:27017/admin, meaning to connect to the admin database in this database

At this point, you can see the output of connection accepted from the console output from the previous command prompt that started the MongoDB server:

The command line db.person.find() prints out two records in the person table in the admin database, indicating that our environment configuration is successful.

Did reading the above help you? If you still want to have further understanding of related knowledge or read more related articles, please pay attention to the industry information channel, thank you for your support.

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