The Windows platform uses a MongoDB shell to connect to a MONGODB server and create a database

Source: Internet
Author: User
Tags mongodb server

The Windows platform uses a MongoDB shell to connect to a MONGODB server and create a database
    1. command line into the bin directory of MongoDB run Mongod.exe
mongod --dbpath c:\data\db

Or find the bin directory of MongoDB and double-click Run Mongod.exe. To output I NETWORK [Thread1] waiting for connections on port 27017.

    1. The command line enters MongoDB's Bin directory to run:
mongo

Open a connection (default is local) when you return to the window where you are running the./mongod command, you can see where the server is connected to MongoDB, and you can see the following information:

2017-09-26T14:53:12.833+0800 I NETWORK  [thread1] connection accepted from 127.0.0.1:54114 #1 (1 connection now open)/*该行表明为一个来自本机的连接*/2017-09-26T14:53:12.864+0800 I NETWORK  [conn1] received client metadata from 127.0.0.1:54114 conn1: { application: { name: "MongoDB Shell" }, driver: { name: "MongoDB Internal Client", version: "3.4.9" }, os: { type: "Windows", name: "Microsoft Windows 8", architecture: "x86_64", version: "6.2 (build 9200)" } }

The command line interface to return to the input MONGO command is as follows:

    • Since it is a JavaScript shell, you can run some simple arithmetic operations:

      > 2 + 2

      4

      > 4+4

      8

    • At this point we can create our own database with the following examples:

Look at all the databases, examples are as follows:

 > show dbs admin  0.000GB local  0.000GB

This is not to see our new database, we can insert a piece of data to it and view it again

> db.testMongoDB.insert({"name":"新建的数据库"})WriteResult({ "nInserted" : 1 })> show dbsadmin   0.000GBlocal   0.000GBtestMongoDB  0.000GB
    • The default database in MongoDB is test, and if you do not create a new database, the collection will be stored in the test database.

The Windows platform uses a MongoDB shell to connect to a MONGODB server and create a database

Related Article

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.