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,
- 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