Join us Sept 17 at .local NYC! Use code WEB50 to save 50% on tickets. Learn more >
MongoDB Event
Docs 菜单
Docs 主页
/
MongoDB 文档

开始体验

在本指南中,您将学习;了解如何在本地或云中创建和连接到MongoDB Atlas部署。要学习;了解如何在自己的基础架构上安装MongoDB Community版或MongoDB Enterprise版,请参阅 MongoDB安装指南

1

在Shell中运行以下命令,安装使用Atlas CLI进行开发所需的开发工具:

brew install mongodb-atlas-cli
brew install docker

前面的命令使用 Homebrew包管理器来安装依赖项。如果没有 Homebrew,可以按照 Homebrew网站 上的说明进行安装。

choco install mongodb-atlas-cli
choco install docker-desktop

前面的命令使用 Chocolatey包管理器来安装依赖项。如果您没有 Chocolatey,可以按照Chocolatey网站上的说明进行安装。

有关安装Atlas CLI 的其他方法,请参阅Atlas CLI安装页面。

2

运行以下命令,并按照Shell中的提示部署单节点集群设立。 如果您没有Atlas帐户,以下命令会提示您创建一个帐户。

atlas deployments setup testing --type local \
--mdbVersion 8.0 --port 27017 --connectWith skip
atlas deployments setup testing --type atlas \
--provider AWS -r us-east-1 --skipSampleData \
--username <Your username> --password <Your password> \
--connectWith skip --force
3

您可以通过运行以下命令,使用MongoDB Shell (mongosh) 连接到您的部署:

atlas deployments connect myTestDb --connectWith mongosh
atlas deployments connect myTestDb --username <Your username> \
--password <Your password> --connectWith mongosh

连接后,您可以运行以下命令来测试连接:

show dbs

该命令会返回部署中的数据库列表。

恭喜!您已成功设立MongoDB Atlas部署并连接到它。要详细学习;了解如何使用MongoDB Shell与部署进行交互,请参阅MongoDB Shell文档。

在下一节中,您将学习;了解如何创建连接到部署并与数据交互的应用程序。

要连接到应用程序中的MongoDB Atlas部署,您可以使用官方MongoDB客户端库之一。

从以下下拉菜单中选择您首选的编程语言,学习;了解如何使用该语言连接到MongoDB Atlas部署。

在此页面上