shell如何创建mongodb用户

浏览:51日期:2023-06-27

问题描述

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

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

问题解答

回答1:

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

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

相关文章: