MongoDB introduction, installation, configuration




Introduction to MongoDB, installation and configuration
1. It is written in C++ language and is an open source database system based on distributed file storage.
2.mongodb: a database stored in a key-value manner. As a NoSQL database, transaction management is not supported.
3. Access rights can be set for each database, and there is an admin database for saving relevant data for managing user rights.
4. Some collections may need to have data in it to display the collection name.
5. Comparing with mySql
Database --> Database
Collection --> Data Table
document --> a record
Data Fields --> Data Fields



MongoDB installation software:
http://blog.csdn.net/HinstenyHisoka/article/details/50178189

MongoDB visual management software: Robomongo.exe


MongoDB installation configuration
1. Install MongoDB software
2. Establish such a directory path C:\mongodb \data\db\, \C:\mongodb\data\log\mongo.log, C:\mongodb\data\mongo.config
3.mongo.config content:
##data files
dbpath=C:\mongodb\data\db

## log file
logpath=C:\mongodb\data\log\mongo.log


4. CDM command window: cd "c:\Program Files\MongoDB\Server\3.2\bin"
5. CDM command window: mongod.exe --config c:\mongodb\data\mongo.config --install
6. Then You can view the service list of the system, run "services.msc", open the system service management interface and find the "Mongodb" service in it, and verify that the above operation has indeed successfully injected the Mongodb service into the system;
7. Start the service, and it will be successful in Windows The MongoDB service is created below, so you don't have to see the annoying command service terminal in the future.


Test
: 1. CDM command window: cd "c:\Program Files\MongoDB\Server\3.2\bin"
2. CDM command window: mongo
3. CDM command window: use testDB //Create a testDB database
4.CDM command window: db.testCollection.insert({"name":"Rookie Tutorial"}) //Add the testCollection collection (if not) to the testDB database, and send the Add {"name":"Rookie Tutorial"} data
to the testCollection collection 5.CDM command window: db.testCollection.find() //View all data in the testCollection collection



MongoDB set access permissions and set users
1.use admin
2.db.createUser({user: "admin",pwd: "admin",roles: [ { role: "root", db: "admin" } ]}) //Add user admin, with the highest root privilege ( User management and database operations), db represents a database that can be accessed, but the highest authority is not limited by this.
3. Enter the system registry (WIN+R-->regedit), find [HKEY_LOCAL_MACHINE-->SYSTEM-- >CurrentControlSet-->Services-->MongoDB] Hit "ImagePath" in the key-value list on the right
[url] "c:\Program Files\MongoDB\Server\3.2\bin\mongod.exe" --config c :\mongodb\data\mongo.config --service changed to
"c:\Program Files\MongoDB\Server\3.2\bin\mongod.exe" --config c:\mongodb\data\mongo.config -auth -- service[/url]
4.mongo
5.use admin
6.db.auth("admin","admin")
7.show collections
8. It is also possible to go to other databases for operation, because it is root privileges.
9. Before creating a new user authority, it is best to clear the user configuration that comes with the system.

Refer to the original text (command usage): http://www.runoob.com/mongodb/mongodb-create-database.html
Reference text (access rights): http://www.tuicool.com/articles/fMZbUzu
Reference text (access rights): http://www.cnblogs.com/zengen/archive/2011/04/23/2025722.html
Reference text (access rights): http://blog.csdn.net/zhao50632/article/details/44922621
Reference text: http://blog.csdn.net/HinstenyHisoka/article/details/50178189
Reference text (MongoDB Foundation ( 6) Security (permission operation): http://blog.csdn.net/kk185800961/article/details/45619863

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326978610&siteId=291194637