How does nodejs use mongoose to connect remotely to mongo on centos

read the official code
mongoose.connect ("mongodb://username:password@host:port/database?options.");

and then it can"t be connected at all. That"s what I wrote

.

mongoose.connect ("mongodb://root:123456@1,2,3,4:66");

is there a great god who has been connected remotely? check it out

reported this error
(node:3784) DeprecationWarning: current URL string parser is deprecated, and wil
l be removed in a future version.) To use the new parser, pass option {useNewUrl
Parser: true} to MongoClient.connect.
failed to connect to the database {"err": "socketHandler", "trace": "", "parseState": {"sizeOfMessage": 75
9714643}}

Mar.28,2021

mongodb at 4.0 (? After that, you need to add

to the login option.
mongoose.connect('mongodb://root:123456@1,2,3,4:66',{ useNewUrlParser: true });

there is another problem. Now mongodb needs to specify the database of the user you are verifying when verifying identity, which is usually admin

.
mongoose.connect('mongodb://root:123456@1,2,3,4:66/admin',{ useNewUrlParser: true });

there is also a problem. If it is Aliyun, port 27017 needs to be opened, otherwise it will not be opened. It will not be opened in the console of Aliyun. What are the entry and exit rules

?
Menu