Heim  >  Fragen und Antworten  >  Hauptteil

shell如何创建mongodb用户

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

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

世界只因有你世界只因有你2727 Tage vor560

Antworte allen(1)Ich werde antworten

  • PHP中文网

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

    创建语句没错,你要找的东西不在mongo的资料里面,你需要了解的是linux shell的用法,关于空格或者引号的转义

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

    Antwort
    0
  • StornierenAntwort