MongoDB Installation and Configuration

Source: Internet
Author: User
Tags auth

MongoDB Installation
1. Upload and unzip the program
Cd/u01/software
TAR-ZXVF mongodb-linux-x86_64-rhel70-3.6.3.tgz

2. Program installation Configuration
MV mongodb-linux-x86_64-rhel70-3.6.3 MongoDB
MV mongodb/opt/
/opt/mongodb
mkdir data
mkdir conf
CD conf
RZ------Upload mongodb.conf file
VI mongodb.conf-------------------Modify file-related paths and turn off user checksum authorization:disabled

3. User-Created
Cd.. /..
Groupadd MongoDB
Useradd mongodb-g MongoDB
Chown-r Mongodb:mongodb./mongodb
CD mongodb/bin/
Ls
Pwd
Vi/etc/profile--------Export path= $PATH:/opt/mongodb/bin
Source/etc/profile
4. Start the program
Mongod--config/opt/mongodb/conf/mongodb.conf------Startup program
Mongo
Ls
Ps-ef|grep MONGO
5. Create DATABASE, user etc (need to close user check "authorization:disabled in mongodb.conf file" when login with Admin)
MONGO localhost:27017/admin-----Administrator Login

Use Hislog-----------------------Create a database
Switched to DB Hislog
DB-----------------------Database creation
Hislog
Show DBS---------------View the database
Admin 0.000GB
Config 0.000GB
Local 0.000GB

Db.createuser ({User: ' his ', pwd: ' Chis2017 ', roles:[{role: ' Dbowner ', db: ' Hislog '}]})--------------------Create user
Db.dropuser ("his")-------------------------delete user
Mongod--shutdown--dbpath/u01/mongodb/data/-----------------Stop Program

VI mongodb.conf--------------------------turn on user check "authorization:enabled"
Mongod--config/opt/mongodb/conf/mongodb.conf--------Startup program
Ps-ef|grep MONGO
6 Login with created user
MONGO Localhost:27017/hislog-u his-p Chis2017

Extended:
MONGO--version

Db.hislog.insert ({"Name": "Rookie Tutorial"})-----Insert data
./mongod--dbpath=/usr/local/mongodb/data--logpath=/usr/local/mongodb/logs--logappend--port=27017--fork--auth
--------Fork Specifies the background run--auth open authentication--dbpath Specify the database directory--logpath specify the log file--logappend log cumulative add

MongoDB users are divided into two kinds, one is the administrator, one is the ordinary user.
Create Administrator
1. Turn off user authentication,

    1. MONGO Localhost:27017/admin
      Use admin
      Db.createuser ({User: ' admin ', pwd: ' 123456 ', roles:[{role: ' Readwriteanydatabase ', db: ' Admin '}]})
      --readanydatabase: Established under the Admin database, can read all the database information
      --readwriteanydatabase: Established under the Admin database, can read and write all database information
      --useradminanydatabase: Set up under the Admin database to manage users of all databases
      --dbadminanydatabase: Established under the Admin database to manage all database information (similar to dbadmin accounts for all databases)

Create a normal user
Use ISDB----ISDB as Database
Db.createuser ({User: ' dev ', pwd: ' 123456 ', roles:[{role: ' Dbowner ', db: ' IsDB '}]})

MongoDB Installation and Configuration

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.