mongo test --eval db.createUser({user:"rwuser", pwd:"titan7vc65x", roles:[{role:"readWrite", db:"test"}]})
用这个命令也不行,我这边需要shell脚本里创建mongodb用户,网上找不到一点信息。
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\"}]})"