Linux 安装mongdb4.0 角色和权限问题

小伯恩 发布于 09/17 19:00
阅读 125
收藏 0

我在Linux上安装了mongdb4.0 并设置了一个用户是admin 角色是userAdmin  

我得conf 配置如下:

# mongod.conf

# for documentation of all options, see:
#   http://docs.mongodb.org/manual/reference/configuration-options/

# where to write logging data.
systemLog:
  destination: file
  logAppend: true
  path: /var/log/mongodb/mongod.log

# Where and how to store data.
storage:
  dbPath: /var/lib/mongo
  journal:
    enabled: true
#  engine:
#  mmapv1:
#  wiredTiger:

# how the process runs
processManagement:
  fork: true  # fork and run in background
  pidFilePath: /var/run/mongodb/mongod.pid  # location of pidfile
  timeZoneInfo: /usr/share/zoneinfo

# network interfaces
net:
  port: 27017
  bindIp: 0.0.0.0  # Enter 0.0.0.0,:: to bind to all IPv4 and IPv6 addresses or, alternatively, use the net.bindIpAll setting.


security:
  authorization: enabled

#operationProfiling:

#replication:

#sharding:

## Enterprise-Only Options

#auditLog:
 

我设置好了用户把登陆验证打开,无法连接到数据库报错和连接信息如下:

[root@localhost /]# mongo mongodb://admin:knotadmin@localhost :27017
MongoDB shell version v4.0.20
connecting to: mongodb://localhost:27017/?gssapiServiceName=mongodb
2020-09-17T06:58:52.736-0400 E QUERY    [js] Error: Authentication failed. :
connect@src/mongo/shell/mongo.js:344:17
@(connect):2:6
exception: connect failed
这个时候我以为是数据库关闭了,但是查询之下并没有,我直接使用mongo 命令 结果如下:

[root@localhost /]# mongo
MongoDB shell version v4.0.20
connecting to: mongodb://127.0.0.1:27017/?gssapiServiceName=mongodb
Implicit session: session { "id" : UUID("346496ce-c1c2-4f21-88dc-3c499b646cbf") }
MongoDB server version: 4.0.20
成功连接了

请问那位大神帮助我看看是什么原因,谢谢

加载中
0
小伯恩
小伯恩

问题已解决,谢谢各位

返回顶部
顶部