Recently has been busy state, English class has not been recently, this should be lazy, wow ah oh; insist...insist...insist. Only after the busy time ... Say it today. Create a database in MongoDB ... Creating a database Check the currently selected database using command DB
>DB
Test
Use command
MongoDB use database_name is used to create a database. This command will create a new database, and if it does not exist, it will return the existing database.
Use basic syntax
Use database_name
Instance:
Use Db_detail
Switched to DB db_detail view the list of databases using the command show DBS
> Show dbs 0.000GB
The database created by MyDB does not exist in the list. To display the database, you need to insert it at least one file
> Db.customer.insert ({name: "Alan Liu"})
> show dbs
db_detail 0.000GB 0.000GB
View data tables under a library
Show Collections
Customer
* In MongoDB default database test. If no database is created, then the collection will be stored in the test database
Write this to think Oracle has user role authorization, that same mongodb should also have, check the data is true: Create user
Type the command:
> Use admin
switched to DB admin
>db.createuser ({User: "admin", pwd: "admin", Roles[{role: " Useradminanydatabase ", DB: Admin"}})
successfully added User: {
"user": "admin",
"roles": [
{
] Role ":" Useradminanydatabase ",
" db ":" Admin "
}
]
}
User Login
First you need to jump to the current database mode by using the use database name, such as usage admin, and then the user logs on
Permission specific details please refer to: https://docs.mongodb.com/master/reference/method/db.createUser/
For you and the kitchen · Meet "