简体   繁体   中英

How to get connection string?

I am using a Compass to manipulate with MongoDB which is installed locally.

Here is the path to host which contains the databases:

在此处输入图像描述

mongodb://localhost:27017/?readPreference=primary&appname=MongoDB%20Compass&directConnection=true&ssl=false

When I click on connect button which you can see in the picture above, I see 4 databases:

在此处输入图像描述

How can I configure what is the connection string to the specific database (for example development) so I can use it on YAML file for connection to the specific database?

Try the following syntax:

mongodb://username:password@host:port/[database]

ie. in your case:

mongodb://localhost:27017/development?readPreference=primary&appname=MongoDB%20Compass&directConnection=true&ssl=false

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM