MongoDB Getting Started Operation summary

Source: Internet
Author: User
Tags auth

First step: Start the database service

1.cmd into the bin directory of MongoDB

2. Enter: Mongod--dbpath "D:\ylkfSoft\mongoData\data\db" starts the database (the path behind--dbpath is the location of the database data that you randomly create after you install the database, You can also create a new folder to put the log in)

Step two: Operate the database (note: Do not close the cmd window above and reopen a cmd)

1.cmd into the bin directory of MongoDB

2. Enter MONGO to enter the database operation location

Note: MongoDB is just installed with no user name and password

Operation:
1. View all databases show DBS

2. Create a database: Use database name (Note: The database you just created is not visible, you need to insert the data before the line)

3. Insert data: DB. database name. Insert (a map);


Specific study: http://www.runoob.com/mongodb/mongodb-create-database.html

Step three: Add user authentication:

1. Access the database (all databases are accessible to users under the admin database)

Use database name

2. Add Users

Db.adduser ("User name", "password")

Note: If you want to use security authentication, the database boot must be started using-auth, and if you do not use even if you configured the security
Authentication, and no need for secure authentication to access query data

Fourth step: Secure Authentication Start Database

1.cmd into the bin directory of MongoDB

2. Input: Mongod--dbpath "D:\ylkfSoft\mongoData\data\db"--logpath "D:\ylkfSoft\mongoData\data\log\MongDB.log"--auth


Fourth step: Connect Visualizer Mongodbvue
1. Delete the original data
2. "D:\ylkfSoft\mongoData\data\db"


Fifth step: MongoDB database backup

Mongodump-h IP--port Port-u user name-p password-d database-o file exists path

1. Do not set user and password, then remove-u-p

2. If the machine is local, remove the-h-port

3. If backing up all databases, remove the-D

Sixth step: Restore the Database

Mongorestore-h IP--port Port-u user name-p password-d database--drop file exists path

MongoDB Getting Started Operation summary

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.