Create a Connection String创建连接字符串
You can connect to your MongoDB deployment by providing a connection URI, also called a connection string, which instructs the driver on how to connect to a MongoDB deployment and how to behave while connected.您可以通过提供连接URI(也称为连接字符串)来连接到您的MongoDB部署,该URI指示驱动程序如何连接到MongoDB部署以及连接时的行为。
The connection string includes the hostname or IP address and port of your deployment, the authentication mechanism, user credentials when applicable, and connection options.连接字符串包括部署的主机名或IP地址和端口、身份验证机制、用户凭据(如果适用)以及连接选项。
To connect to an instance or deployment not hosted on Atlas, see Other Ways to Connect to MongoDB.要连接到未托管在Atlas上的实例或部署,请参阅连接到MongoDB的其他方法。
Find your MongoDB Atlas Connection String查找MongoDB Atlas连接字符串
To retrieve your connection string for the deployment that you created in the previous step, log into your Atlas account and navigate to the Database section and click the Connect button for your new deployment.要检索您在上一步中创建的部署的连接字符串,请登录您的Atlas帐户并导航到“数据库”部分,然后单击新部署的“连接”按钮。

Proceed to the Connect your application section and select "Node.js" from the Driver selection menu and the version that best matches the version you installed from the Version selection menu.继续“连接应用程序”部分,从驱动程序选择菜单中选择“Node.js”,并从“版本”选择菜单选择与您安装的版本最匹配的版本。
Select the Password (SCRAM) authentication mechanism.选择密码(SCRAM)身份验证机制。
Deselect the Include full driver code example to view the connection string.取消选择包含完整驱动程序代码示例以查看连接字符串。
Update the Placeholders更新占位符
Paste this connection string into a a file in your preferred text editor and replace the "<username>" and "<password>" placeholders with your database user's username and password.将此连接字符串粘贴到首选文本编辑器中的文件中,并用数据库用户的用户名和密码替换“<用户名>”和“<密码>”占位符。
Save this file to a safe location for use in the next step.将此文件保存到安全位置,以便在下一步中使用。
After completing these steps, you should have a connection string that contains your database username and password.完成这些步骤后,您应该有一个包含数据库用户名和密码的连接字符串。
If you run into issues on this step, ask for help in the MongoDB Community Forums如果在此步骤中遇到问题,请在MongoDB社区论坛 or submit feedback using the Share Feedback tab on the right or bottom right side of this page.
中寻求帮助,或使用此页面右侧或右下角的“共享反馈”选项卡提交反馈。