Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the relevant actions of MongoDB management users?

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article introduces you what is the relevant operation of MongoDB management users, the content is very detailed, interested friends can refer to, hope to be helpful to you.

List all users

Mongo

Use admin

Db.system.users.find ()

Disable authentication mode

/ etc/mongod.conf

Noauth = true

Auth = false

Create a user

The user is database-based, and the user created on the admin database belongs to the administrator user.

The creation of administrative users

Users with all database administration permissions

Use admin

Db.createUser ({

User: "user name"

Pwd: "password"

Roles: [

{

Role: "userAdminAnyDatabase"

Db: "admin"

}

]

})

Users with specific database administrative permissions

Use "Database name"

Db.createUser ({

User: "user name"

Pwd: "password"

Roles: [

{

Role: "userAdmin"

Db: "Database name"

}

]

})

General user

Db "Database name"

Db.createUser ({

User: "user name"

Pwd: "password"

Roles: [

{

Role: "read", # or "readWrite"

Db: "Database name"

}

]

})

User authentication

Db.auth ("user name", "password")

Verification initiated by mongo shell

$mongo "Database name"-u "user name"-p "password"

Delete user

Use "Database name"

Db.system.users.remove ({user: "username to delete"})

Example: create a database user with read and write access to the data

Create a database user with read and write permissions to the database

Use dbname

Db.createUser ({user: "dbuser", pwd: "dbuseradmin", roles: [{role: "readWrite", db: "dbname"}]})

Database user login

Mongo dbname-u dbuser-p dbduseradmin

On the MongoDB management of users what is to share here, I hope that the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report