Installation mongoDB
Plug-in with Studio-3T is equivalent to the mysql navicat
not set a username and password
Getting the MongoDB
The first is based on the concept
Basic concepts
Database
Query Database
show dbs
Create a database
use DATABASE_NAME
Select Database
switched to db 数据库名字
Delete the database
to switch to the database below
db.dropDatabase()
Create a table
collection is called the table in mongoDB
Create a collection
knife database below
db.createCollection(name,options)
Delete collection
Also in the following database
db.集合名称.drop()
Insert the document
file is the equivalent of mysql record
db.COLLECTION_NAME.insert(document)
列子
db.student.insert({"name":"黑马程序员","age":10})
Update Documentation
db.collection.update( <query>, <update>, <options> )query:查询条件,相当于sql语句的where update:更新文档内容 options:选项
db.student.update({"name":"黑马程序员"},{"name":"北京黑马程序员","age":10})
Flexible data format
Delete Document
db.student.remove(<query>)
query: delete conditions, the equivalent of sql statement where
Query document
db.student.find({"name":"黑马程序员"})
db.student.find({"name":"黑马程序员"},{name:1,age:1,_id:0})
Create a user
mongo>db.createUser( { user: "<name>", pwd: "<cleartext password>", customData: { <any information> }, roles: [ { role: "<role>", db: "<database>" } | "<role>", ... ]} )
Liezi
use admin db.createUser( { user:"root", pwd:"123", roles:[{role:"root",db:"admin"}] } )
Open User name and password authentication in the configuration file, bin directory of the config file
add
security:
authorization: enabled
Then restart the service
discovery can log in above, but you want to operate when the authority was prompted
Exit to the login screen
mongo.exe ‐u root ‐p 123 ‐‐authenticationDatabase admin
You can direct the
We can also add users in studio.3T the
configuration information