To set the connection authentication permission on Windows to MongoDB:
MongoDB default is not authentication, default no account, now talk about how to set up the account and password
1, first enter C:\mongodb\bin below double-click Run mongo.exe start database.
2, next in the Mongo.exe to create the user administrator code as follows:
2.1 Advanced Admin Database command: Use admin
2.2 Login Authentication command for super User under Admin database: Db.auth ("Ultra", "123456")//return 1 indicates successful login
2.3 Create a new Database command in Superuser state: Use new database name
2.4 Insert a piece of data in the new database (otherwise the database will not be empty) command: Db.srcollection.insert ({"id": "" "," Name ":" Xiaohong "})
2.5 Create a new user in the new database, giving the read-write command:
Db.createuser ({User: "Sydo", pwd: "123456", Roles:[{role: "ReadWrite", DB: "New database Name"]})
3. Users connect to the database via the client tool and need to verify the account and password.
First, configure the MongoDB steps on Linux:
1. First step to download the Linux version of MongoDB installation package in Windows
2. Copy and paste the installation package into a Linux virtual machine
3. Unzip the folder under the install package into Linux
Command: #tar-zxvf mongodb-linux-x86_64-2.6.9.gz
4. Create a log and data file under the root directory of the MongoDB installation folder
4.1 Create Data folder under the MongoDB Folder command: mkdir data
4.2 Create an empty DB folder under the Data Folder command: MkDir db
4.3 Create Logs folder under the MongoDB Folder command: mkdir logs
4.4 Create an empty mongo.log file command in logs: Touch Mongo.log
4.5 Create a Mongo.config file under the MongoDB Folder command: Touch mongo.config
4.6 Enter the Mongo.config file to write the following configuration contents into command: VI mongo.config
Mongo.config Configuration content: Dbpath=/home/sydo/mongodb/data
Logpath=/home/sydo/mongodb/logs/mongo.log
Logappend=true
Journal=true
Quiet=true
port=27017
5. Write a startup script in the bin that launches Mongod.exe as follows:
#! /bin/sh
Nohup./mongod-f/home/sydo/mongodb/mongo.config &
Second, configure the connection authentication steps for MongoDB on the Linux server:
1. Add the connection authentication in the Mongo.config configuration file: Auth=true
2. Go to the installation folder of MongoDB on the server and open the Bin subfolder to run the service-side database by command mongod:./start.sh
Start.sh is a small script that he wrote in the Shell to run fast in shelll Mongod.exe
3. Open the client's database in the Settings command:./mongo
4. Advanced Admin Database command: Use admin
5. Perform superuser login verification command under Admin database: Db.auth ("Ultra", "123456")
6. Create a new Database command in the Superuser login state: Use new database name
7. Insert a piece of data into the new database (otherwise the database will not be empty) command: Db.srcollection.insert ({"id": "" "," Name ":" Xiaohong "})
8. Create a new user in the new database and give the read-write command:
Db.createuser ({User: "Sydo", pwd: "123456", Roles:[{role: "ReadWrite", DB: "New database Name"]})
9. Now the user can connect the database with a tool on the client.
How to deploy MongoDB in Linux and set up connection authentication