mongodb错误解决方案

问题描述:

因为一段时间没有使用MongoDB数据库,所以今天出现一个问题,在进入MongoDB数据库后执行show dbs等命令基本都会出现一个错误,如下:

MongoDB Enterprise > show dbs;
2018-05-19T12:05:01.313+0800 E QUERY [thread1] Error: listDatabases failed:{
"ok" : 0,
"errmsg" : "not authorized on admin to execute command { listDatabases: 1.0, $db: \"admin\" }",
"code" : 13,
"codeName" : "Unauthorized"
} :
_getErrorWithCode@src/mongo/shell/utils.js:25:13
Mongo.prototype.getDBs@src/mongo/shell/mongo.js:65:1
shellHelper.show@src/mongo/shell/utils.js:820:19
shellHelper@src/mongo/shell/utils.js:710:15
@(shellhelp2):1:1

我到现在也不知道具体错在哪里,看错误像权限问题,但按照网上的一些权限方法解决,没有用。

最后,我的MongoDB安装步骤是按照百度https://jingyan.baidu.com/article/d5c4b52bef7268da560dc5f8.html装的,我就把其中的data数据和log数据删除,重新建立新的文件,再将服务重新安装。前提是你必须把数据库先关闭。这样就解决了。

猜你喜欢

转载自www.cnblogs.com/pig1314/p/9059972.html