Various problems encountered when installing and configuring MongoDB during development

1. Install version 6 or below

To install MongoDB version 6 or below, please refer to the following bloggers

->自动安装版

(26 messages) MongoDB installation (super detailed)_AI bro's blog-CSDN blog

<-

2. Install version 6 and above

To install MongoDB version 6 and above, please refer to the following bloggers

->自动安装版

MongoDB 6.x installation tutorial under Windows and Linux (detailed) -Alibaba Cloud Developer Community (aliyun.com)

<-

3. Install version 6 or below (unzipped version)

To install the decompressed version of MongoDB6 or below, please refer to the following bloggers

->解压版

Installation and use of MongoDB under Windows - Zhihu (zhihu.com)

<-

4. Configure the local Windows MongoGB service

Install and configure the relevant information. If you want to easily start MongoDB locally, please refer to the following bloggers. The content is probably at the back, mainly for this to be run in the bin directory of cmd.

ps: mongod -dbpath "D:\MyApp\Mongodb\Server\data\db" -logpath "D:\MyApp\Mongodb\Server\data\log\mongo.log" -install -serviceName "MongoDB"Pay attention to modify your path

->自动安装版

MongoDB 6.x installation tutorial under Windows and Linux (detailed) -Alibaba Cloud Developer Community (aliyun.com)

<-

5. Navicat connects to the remote mongodb database

readWriteAnyDatabaseBeginners should pay special attention to the fact that admin is the database of the system. You can set the account, password and permissions for permissions root. At this time, you can only test whether the login is successful under Navicat. Remember to reconfigure the account password and permissions for the newly created new database .

Otherwise this error will occurCaused by: com.mongodb.MongoCommandException: Command failed with error 18 (AuthenticationFailed): 'Authentication failed.' on server 127.0.0.1:27017. The full response is {"ok": 0.0, "errmsg": "Authentication failed.", "code": 18, "codeName": "AuthenticationFailed"}

Because: Each database in MongoDB is independent of each other and has independent permissions. The correct approach is to reconfigure the account password and permissions for the newly created new database .

To connect navicat to the remote mongodb database, you can refer to the following bloggers:

->连接远程

(26 messages) navicat connects to remote mongodb database_How navicat connects to mongodb_A programmer 88's blog-CSDN blog

<-

6. IP inconsistency problem

Inconsistent ip exception when MongoDB is runningcom.mongodb.MongoSocketOpenException: Exception opening socket

如果本地测试可以检查是否是127.0.0.1,部署到远程服务器上就需要修改配置文件, 在conf/Mongodb.conf里添加bind_ip=0.0.0.0, 添加这个参数是让任何的ip可以连接MongoDB 。

具体情况具体分析,开发过程中解决问题是多方面的,从各种博主中寻找部分正解运用到自己的项目中,即可解决问题,上述提到的博主都是结合经验参考,觉得方案可行的

Guess you like

Origin blog.csdn.net/qq_51601665/article/details/132989602