MongoDB创建用户报错command createUser requires&nbs

1、执行创建用户报错如下:

2、解决方法

2.1 关闭 MongoDB

/usr/local/mongodb/bin/mongod -f /usr/local/mongodb/mongod.conf --shutdown

2.2 修改配置文件

vim /usr/local/mongodb/mongod.conf

将security.authorization值从enabled改为disabled

2.3 启动MongoDB

/usr/local/mongodb/bin/mongod -f /usr/local/mongodb/mongod.conf

3、验证

use admin

db.createUser({user:"admin",pwd:"shenz2024",roles:[{role:"root",db:"admin"}]});

以上就是MongoDB创建用户报错command createUser requires authentication的解决方法的详细内容,更多关于MongoDB创建用户报错authentication的资料请关注站长网其它相关文章!