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

How to modify the database authentication mechanism in MongoDB3.0

2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

This article introduces you how to modify the database authentication mechanism in MongoDB3.0, the content is very detailed, interested friends can refer to, hope to be helpful to you.

Modification requirements: MongoDB3.0 's current authentication mechanism is SCRAM-SHA-1, which needs to be changed to the old authentication mechanism MONGODB-CR.

The methods are as follows:

> use admin

Switched to db admin

> db.system.version.findOne ({"_ id": "authSchema"})

{"_ id": "authSchema", "currentVersion": 5}

A currentVersion of 5 means that the authentication mechanism of the current database is SCRAM-SHA-1, which needs to be changed to a value of 3 for MONGODB-CR,currentVersion.

> var schema = db.system.version.findOne ({"_ id": "authSchema"})

> schema.currentVersion = 3

three

> db.system.version.save (schema)

WriteResult ({"nMatched": 1, "nUpserted": 0, "nModified": 1})

> db.system.version.find ()

{"_ id": "authSchema", "currentVersion": 3}

Here it means that the modification has been successful.

Create a database user

> use test

> db.createUser ({user: 'test', pwd:' test123', roles: [{role: "readWrite", db: "test"}]})

Successfully added user: {

"user": "test"

"roles": [

{

"role": "userAdminAnyDatabase"

"db": "admin"

}

]

View the authentication method:

> use admin

> db.system.users.find ()

{"_ id": "admin.admin", "user": "admin", "db": "admin", "credentials": {"SCRAM-SHA-1": {"iterationCount": 10000, "salt": "kAyNTjjA56SjKNB+voW/ow==", "storedKey": "S0QMFvrojLTl4fYN4zz6HL3rlRc =", "serverKey": "m0eym4YQikIufcR8JxcIRfdDrg ="}, "roles": [{"role": "userAdminAnyDatabase" "db": "admin"}]}

{"_ id": "test.test", "user": "test", "db": "test", "credentials": {"MONGODB-CR": "cf75a14725e3655983a84ea5f5b25438"}, "roles": [{"role": "readWrite", "db": "test"}]}

On how to modify the database authentication mechanism in MongoDB3.0 to share here, I hope 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: 299

*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