search

Home  >  Q&A  >  body text

shell如何创建mongodb用户

mongo test --eval db.createUser({user:"rwuser", pwd:"titan7vc65x", roles:[{role:"readWrite", db:"test"}]})

用这个命令也不行,我这边需要shell脚本里创建mongodb用户,网上找不到一点信息。

世界只因有你世界只因有你2757 days ago579

reply all(1)I'll reply

  • PHP中文网

    PHP中文网2017-05-02 09:20:54

    The creation statement is correct. What you are looking for is not in the mongo information. What you need to know is the usage of linux shell and the escaping of spaces or quotes

    mongo test --eval "db.createUser({user:\"rwuser\", pwd:\"titan7vc65x\", roles:[{role:\"readWrite\", db:\"test\"}]})"

    reply
    0
  • Cancelreply