亚洲激情专区-91九色丨porny丨老师-久久久久久久女国产乱让韩-国产精品午夜小视频观看

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

MongoDB 中怎么修改用戶密碼

發布時間:2021-07-16 16:13:14 來源:億速云 閱讀:256 作者:Leah 欄目:關系型數據庫

本篇文章為大家展示了MongoDB 中怎么修改用戶密碼,內容簡明扼要并且容易理解,絕對能使你眼前一亮,通過這篇文章的詳細介紹希望你能有所收獲。

    1、登陸mongodb數據庫集群主庫,創建超級管理用戶

db.createUser(  

{  

    user:"firstset",   

    pwd:"firstset",  

    roles:[{role:"userAdminAnyDatabase",db:"admin"}]  

}  

);  

    2、修改zhul的密碼,檢查mogodb進程,注意端口號

ps -ef|grep mongod

mongo    10836     1  0 09:02 ?        00:00:03 mongod --dbpath /opt/mongo/data/dns_repset1 --port 10001 --replSet firstset --oplogSize 512 --rest --fork --logpath /opt/mongo/logs/firstset/firstset.log --logappend --nojournal --directoryperdb --keyFile /opt/mongo/keyfile/keyfile

mongo    10997  9767  0 09:09 pts/3    00:00:00 grep --color=auto mongod

    3、修改zhul的密碼,檢查當前數據庫是否免密登陸

[mongo@mongo1 keyfile]$ mongo  --port 10001 

MongoDB shell version: 3.2.11-49-g52b68fa

connecting to: 127.0.0.1:10001/test

firstset:PRIMARY> show dbs

2019-10-24T09:09:31.298+0800 E QUERY    [thread1] Error: listDatabases failed:{

"ok" : 0,

"errmsg" : "not authorized on admin to execute command { listDatabases: 1.0 }",

"code" : 13

} :

_getErrorWithCode@src/mongo/shell/utils.js:25:13

Mongo.prototype.getDBs@src/mongo/shell/mongo.js:62:1

shellHelper.show@src/mongo/shell/utils.js:761:19

shellHelper@src/mongo/shell/utils.js:651:15

@(shellhelp2):1:1

firstset:PRIMARY> exit

bye

    通過驗證,當前數據庫試用了keyfile安全認證校驗,免密登陸會拒絕執行任何命令

4、修改zhul的密碼,如果知曉被修改用戶的密碼可以使用賬號密碼登錄,也可以取消keyfile安全限制

免密登陸修改相關用戶的密碼后,再啟用keyfile安全認證

[mongo@mongo1 keyfile]$ mongo  -u firstset  -p firstset  --port 10001

MongoDB shell version: 3.2.11-49-g52b68fa

connecting to: 127.0.0.1:10001/test

Server has startup warnings: 

2019-10-24T09:02:45.827+0800 I CONTROL  [main] ** WARNING: --rest is specified without --httpinterface,

2019-10-24T09:02:45.827+0800 I CONTROL  [main] **          enabling http interface

2019-10-24T09:02:46.023+0800 I CONTROL  [initandlisten] 

2019-10-24T09:02:46.023+0800 I CONTROL  [initandlisten] ** WARNING: The server is started with the web server interface and access control.

2019-10-24T09:02:46.023+0800 I CONTROL  [initandlisten] **          The web interfaces (rest, httpinterface and/or jsonp) are insecure 

2019-10-24T09:02:46.023+0800 I CONTROL  [initandlisten] **          and should be disabled unless required for backward compatibility.

2019-10-24T09:02:46.023+0800 I CONTROL  [initandlisten] 

2019-10-24T09:02:46.023+0800 I CONTROL  [initandlisten] 

2019-10-24T09:02:46.023+0800 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.

2019-10-24T09:02:46.023+0800 I CONTROL  [initandlisten] **        We suggest setting it to 'never'

2019-10-24T09:02:46.023+0800 I CONTROL  [initandlisten] 

2019-10-24T09:02:46.023+0800 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.

2019-10-24T09:02:46.024+0800 I CONTROL  [initandlisten] **        We suggest setting it to 'never'

2019-10-24T09:02:46.024+0800 I CONTROL  [initandlisten] 

firstset:PRIMARY> show dbs;

admin       0.000GB

dns_testdb  0.004GB

local       0.008GB

firstset:PRIMARY> db.updateUser("firstset",{pwd:"rootroot"});

firstset:PRIMARY> exit

bye

    5、驗證密碼修改

--錯誤的用戶名或者密碼登錄被拒絕

[mongo@mongo1 keyfile]$ mongo  -u firstset  -p firstset  --port 10001 

MongoDB shell version: 3.2.11-49-g52b68fa

connecting to: 127.0.0.1:10001/test

2019-10-24T09:11:35.167+0800 E QUERY    [thread1] Error: Authentication failed. :

DB.prototype._authOrThrow@src/mongo/shell/db.js:1441:20

@(auth):6:1

@(auth):1:2

exception: login failed

--使用正確的用戶名和密碼登錄后可以正常執行操作

[mongo@mongo1 keyfile]$ mongo  -u firstset  -p rootroot --port 10001

MongoDB shell version: 3.2.11-49-g52b68fa

connecting to: 127.0.0.1:10001/test

Server has startup warnings: 

2019-10-24T09:02:45.827+0800 I CONTROL  [main] ** WARNING: --rest is specified without --httpinterface,

2019-10-24T09:02:45.827+0800 I CONTROL  [main] **          enabling http interface

2019-10-24T09:02:46.023+0800 I CONTROL  [initandlisten] 

2019-10-24T09:02:46.023+0800 I CONTROL  [initandlisten] ** WARNING: The server is started with the web server interface and access control.

2019-10-24T09:02:46.023+0800 I CONTROL  [initandlisten] **          The web interfaces (rest, httpinterface and/or jsonp) are insecure 

2019-10-24T09:02:46.023+0800 I CONTROL  [initandlisten] **          and should be disabled unless required for backward compatibility.

2019-10-24T09:02:46.023+0800 I CONTROL  [initandlisten] 

2019-10-24T09:02:46.023+0800 I CONTROL  [initandlisten] 

2019-10-24T09:02:46.023+0800 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.

2019-10-24T09:02:46.023+0800 I CONTROL  [initandlisten] **        We suggest setting it to 'never'

2019-10-24T09:02:46.023+0800 I CONTROL  [initandlisten] 

2019-10-24T09:02:46.023+0800 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.

2019-10-24T09:02:46.024+0800 I CONTROL  [initandlisten] **        We suggest setting it to 'never'

2019-10-24T09:02:46.024+0800 I CONTROL  [initandlisten] 

firstset:PRIMARY> show dbs;

admin       0.000GB

dns_testdb  0.004GB

local       0.008GB

firstset:PRIMARY> use admin

switched to db admin

firstset:PRIMARY> show collections;

system.users

system.version

firstset:PRIMARY> db.system.users.find();

{ "_id" : "test.firstset", "user" : "firstset", "db" : "test", "credentials" : { "SCRAM-SHA-1" : { "iterationCount" : 10000, "salt" : "ISdrb4a3Cc0A59vXEUxjOg==", "storedKey" : "qPn44VuZrJ6QwWzOMBq90vZ5eAo=", "serverKey" : "rz+CDSlpXHKvUDGg0PCnG2GZCjk=" } }, "roles" : [ { "role" : "root", "db" : "admin" } ] }

firstset:PRIMARY> use dns_testdbuse dns_testdb

switched to db dns_testdb

firstset:PRIMARY> show collections;

test_collection

firstset:PRIMARY> db.test_collection.findOne();

{

"_id" : ObjectId("5d8434a5b138ddafc446e13b"),

"name" : "cow",

"user_id" : 48149,

"boolean" : false,

"added_at" : ISODate("2019-09-20T02:08:37.116Z"),

"number" : 1743

}

firstset:PRIMARY> 

firstset:PRIMARY> rs.status();

{

"set" : "firstset",

"date" : ISODate("2019-10-24T01:13:15.006Z"),

"myState" : 1,

"term" : NumberLong(7),

"heartbeatIntervalMillis" : NumberLong(2000),

"members" : [

{

"_id" : 0,

"name" : "192.168.192.251:10001",

"health" : 1,

"state" : 1,

"stateStr" : "PRIMARY",

"uptime" : 630,

"optime" : {

"ts" : Timestamp(1571879490, 1),

"t" : NumberLong(7)

},

"optimeDate" : ISODate("2019-10-24T01:11:30Z"),

"electionTime" : Timestamp(1571879010, 1),

"electionDate" : ISODate("2019-10-24T01:03:30Z"),

"configVersion" : 1,

"self" : true

},

{

"_id" : 1,

"name" : "192.168.192.252:10001",

"health" : 1,

"state" : 2,

"stateStr" : "SECONDARY",

"uptime" : 566,

"optime" : {

"ts" : Timestamp(1571879490, 1),

"t" : NumberLong(7)

},

"optimeDate" : ISODate("2019-10-24T01:11:30Z"),

"lastHeartbeat" : ISODate("2019-10-24T01:13:13.320Z"),

"lastHeartbeatRecv" : ISODate("2019-10-24T01:13:13.259Z"),

"pingMs" : NumberLong(0),

"syncingTo" : "192.168.192.251:10001",

"configVersion" : 1

},

{

"_id" : 2,

"name" : "192.168.192.250:10001",

"health" : 1,

"state" : 7,

"stateStr" : "ARBITER",

"uptime" : 593,

"lastHeartbeat" : ISODate("2019-10-24T01:13:13.301Z"),

"lastHeartbeatRecv" : ISODate("2019-10-24T01:13:13.185Z"),

"pingMs" : NumberLong(0),

"configVersion" : 1

}

],

"ok" : 1

}

firstset:PRIMARY> 


上述內容就是MongoDB 中怎么修改用戶密碼,你們學到知識或技能了嗎?如果還想學到更多技能或者豐富自己的知識儲備,歡迎關注億速云行業資訊頻道。

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

津南区| 临西县| 乐亭县| 区。| 金溪县| 新安县| 霍邱县| 清原| 抚远县| 南康市| 乌鲁木齐市| 清水县| 大连市| 灵山县| 沙湾县| 朝阳市| 沂水县| 浏阳市| 集安市| 临夏县| 华亭县| 比如县| 普兰县| 和田市| 卢湾区| 上高县| 绥芬河市| 洮南市| 宝清县| 西丰县| 南宫市| 来宾市| 义马市| 朔州市| 元谋县| 寻乌县| 屏边| 永新县| 马龙县| 赤峰市| 化州市|