Installation method of Docker MongoDB single machine

Source: Internet
Author: User
Tags mongodb docker hub docker run
Brief Introduction

MongoDB (from "humongous") is a cross-platform, document-oriented database. As a NoSQL database, MongoDB avoids the traditional structure of a relational database based on tables, and a JSON-like document (MongoDB called the Bson format) with dynamic patterns makes it easier and faster to integrate data in certain types of applications. MongoDB is a combination of the GNU Affero General Public License and Apache license, and is free open source software. Using Docker to install stand-alone version is a quicker way. Installation Method

Installation methods are as follows: First, you can open the Docker hub to retrieve MongoDB, search for your favorite MongoDB entries. Like I'm inclined to choose the official version for easy expansion or subsequent operation.

Use Docker pull MONGO to pull a Docker mirror to start a service with a password

Docker run--name mongo-p 27017:27017-v/home/data/mongodb/data (mapped to its own DB data file storage location):/data/db-d MONGO
After startup, Docker exec-it Some-mongo MONGO admin connects to admin to add the initial administrator user, create the database, and have granted permissions.
> Db.createuser ({User: ' JSmith ', pwd: ' Some-initial-password ', roles: [{role: "Useradminanydatabase", DB: "Admin"} ];(Create Admin user) 
> db.createuser ({User: ', pwd: ' Root ', roles:[{role: ' Root ', db: ' admin '}}) create root user
> Db.auth ("username", "password") to admin account authorization
> Use octblog database
> Db.createuser ({User: "Gevin", pwd: "Gevin",
  roles : [{role: ' ReadWrite ', DB: "Octblog"},{Role: "ReadWrite", DB: "Octblog-log"}]}) Create an ordinary read-write user
This allows you to access the database externally. Appendix

MongoDB Permission Description

A MongoDB built-in roles official website document introduction: http://docs.mongoing.com/manual-zh/reference/built-in-roles.html
B about MongoDB built-in roles, We can probably be divided into the following to say a few words.
B.1 DB user Roles (Database users role): Read, ReadWrite
B.2 Database administration Roles (databases Administrative roles: Dbadmin, Dbowner, useradmin
B.3 culster Administration Roles (Administrators group, management for the entire system): Clusteradmin, Clustermanager, Clustermonitor, Hostmanager
B.4 Backup and Restoration Roles (Backup restore role Group): Backup, restore
b.5 all-database, Rol ES (all database roles): Readanydatabase, Readwriteanydatabase, Useradminanydatabase, dbadminanydatabase
b.6 Superuser Roles (     Super Admin): Root, (Dbowner, useradmin, useradminanydatabase These role roles provide any data any user's ability to have any permissions, users with this role can define their own permissions on any database)
B.7 Internal Role (internal roles, generally not recommended settings): __system
C on the meaning of each role above, please go to the official website or this article to see, the address is: http://www.cnblogs.com/SamOk /p/5162767.html

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.