Get the App
SLTechnology News&Howtos  ›  Database  › 

How to build MongoDB environment

Shulou Source: shulou.com Published: 2022-05-31 21:11:38 10月22日 Update

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.

Tags: Command data database process environment server prompt service name meaning console file help control generate monitor input output clear successful Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info NVidia Shulou Technology Linux Apple