mongodb连接字符串

mongodb://localhost:27017

mongodb://root:123456@localhost:27017/testdb?authSource=admin


1、连接本地数据库服务器,端口是默认的。

mongodb://localhost

2、使用用户名fred,密码foobar登录localhost的admin数据库。

mongodb://fred:foobar@localhost

3、使用用户名fred,密码foobar登录localhost的baz数据库

mongodb://fred:foobar@localhost/baz

4、连接 replica pair, 服务器1为example1.com服务器2为example2

mongodb://example1.com:27017,example2.com:27017

5、连接 replica set 三台服务器 (端口 27017, 27018, 和27019)

mongodb://localhost,localhost:27018,localhost:27019

原文链接:https://blog.csdn.net/studyofnet/article/details/84545021

posted @ 2024-04-02 22:52  BloggerSb  阅读(85)  评论(0编辑  收藏  举报