我是靠谱客的博主 怕黑招牌,最近开发中收集的这篇文章主要介绍mongodb遇到的错误,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

错误一.com.mongodb.MongoCommandException: Command failed with error -1: ‘can’t find ns’ on server 127.0.0.1:27017. The full response is { “ok” : 0.0, “errmsg” : “can’t find ns” }

错误二.no geo indices for geoNear

上面两个错误

查询店铺的时候报错,解决办法

创建索引

[lzq@localhost bin]$ ./mongo
MongoDB shell version v4.0.2
connecting to: mongodb://127.0.0.1:27017
MongoDB server version: 4.0.2
Server has startup warnings:
2020-09-10T04:37:31.046-0400 I STORAGE
[initandlisten]
2020-09-10T04:37:31.046-0400 I STORAGE
[initandlisten] ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine
2020-09-10T04:37:31.046-0400 I STORAGE
[initandlisten] **
See http://dochub.mongodb.org/core/prodnotes-filesystem
2020-09-10T04:37:32.576-0400 I CONTROL
[initandlisten]
2020-09-10T04:37:32.576-0400 I CONTROL
[initandlisten] ** WARNING: Access control is not enabled for the database.
2020-09-10T04:37:32.576-0400 I CONTROL
[initandlisten] **
Read and write access to data and configuration is unrestricted.
2020-09-10T04:37:32.576-0400 I CONTROL
[initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.
2020-09-10T04:37:32.576-0400 I CONTROL
[initandlisten]
---
Enable MongoDB's free cloud-based monitoring service, which will then receive and display
metrics about your deployment (disk utilization, CPU, operation statistics, etc).
The monitoring data will be available on a MongoDB website with a unique URL accessible to you
and anyone you share the URL with. MongoDB may use this information to make product
improvements and to suggest MongoDB products and deployment options to you.
To enable free monitoring, run the following command: db.enableFreeMonitoring()
To permanently disable this reminder, run the following command: db.disableFreeMonitoring()
---
> use flash-waimai;
switched to db flash-waimai
> db.bingos.createIndex({location: "2dsphere"})
{
"createdCollectionAutomatically" : true,
"numIndexesBefore" : 1,
"numIndexesAfter" : 2,
"ok" : 1
}
> db.shops.createIndex({location: "2dsphere"})
{
"createdCollectionAutomatically" : true,
"numIndexesBefore" : 1,
"numIndexesAfter" : 2,
"ok" : 1
}

最后

以上就是怕黑招牌为你收集整理的mongodb遇到的错误的全部内容,希望文章能够帮你解决mongodb遇到的错误所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(32)

评论列表共有 0 条评论

立即
投稿
返回
顶部