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"}]}); |