mongoDB 修改密码

2020-11-17 10:05:53

mongodb修改密码方法一,利用db.addUser

> db.addUser('tank2','111')
{
    "_id" : ObjectId("529e6f1c8d95afd190add450"),
    "user" : "tank2",
    "readOnly" : false,
    "pwd" : "6b4334d2c97c526e6a11b2f9ce1996e0"
}

有人会问,这个不是添加用户的方法吗。不错这是添加用户的方法,但是如果用户名相同,密码不同的话,就会更新密码。


mongodb修改密码方法二,利用db.changeUserPassword

> db.changeUserPassword('tank2','test');

错误做法,直接更新表

> db.system.users.update({"_id" : ObjectId("529e67553992b24438d5e315")},{"user":"tank2","readOnly" : false,"pwd":"123"})
> db.system.users.find();
{ "_id" : ObjectId("529e5f8474b4c660718a70f3"), "user" : "tank1", "readOnly" : false, "pwd" : "35dd47abff098f5b4f0b567db8edeac5" }
{ "_id" : ObjectId("529e67553992b24438d5e315"), "user" : "tank2", "readOnly" : false, "pwd" : "123" }  //这样就不对了


  • 2017-02-10 16:22:13

    git历史记录查询

    查看提交历史:git log 查看提交历史并显示版本间的差异:git log -p 查看指定历史:git log xxx(sha1值) -p 查看提交历史(指定时间):

  • 2017-02-13 17:50:05

    cURL error 60: SSL certificate problem: unable to get local issuer certificate

    Drupal 8 version uses Guzzle Http Client internally, but under the hood it may use cURL or PHP internals. If you installed PHP cURL on your PHP server it typically uses cURL and you may see an exception with error Peer certificate cannot be authenticated with known CA certificates or error code CURLE_SSL_CACERT (60).

  • 2017-02-16 08:09:01

    HTML中PRE和p的区别

    pre 元素可定义预格式化的文本。被包围在 pre 元素中的文本通常会保留空格和换行符。而文本也会呈现为等宽字体。 <pre> 标签的一个常见应用就是用来表示计算机的源代码。

  • 2017-02-16 15:14:14

    动态加载js和css

    开发过程中经常需要动态加载js和css,今天特意总结了一下常用的方法。