别问为什么不副本集和分片了,小公司没有技术,两个后台都是应届生(第一次使用mongodb,上手确实不难,但配置着实头疼)
设置密码的情况下
使用mongo shell和mongo compass均可以连接数据库,但在springboot里面就会一直报错,各种uri都试了个遍
报错信息:
org.springframework.data.mongodb.UncategorizedMongoDbException: Command failed with error 13 (Unauthorized): ‘command count requires authentication’ on server ip:27017. The full response is {“ok”: 0.0, “errmsg”: “command count requires authentication”, “code”: 13, “codeName”: “Unauthorized”}; nested exception is com.mongodb.MongoCommandException: Command failed with error 13 (Unauthorized): ‘command count requires authentication’ on server ip:27017. The full response is {“ok”: 0.0, “errmsg”: “command count requires authentication”, “code”: 13, “codeName”: “Unauthorized”}
配置文件:
dbpath = /usr/develop/mongodb/data/db
logpath = /usr/develop/mongodb/logs/mongodb.log
port = 27017
fork = true
#auth = true
bind_ip = 0.0.0.0
已经解决了,是全局配置文件的问题
老哥,详细怎么解决的呢?
查看一下你的@Configuration类里面有没有建立连接的,如果有,改成非用户名密码的方式
Spring怎么连的呢?