Docs HomeMongoDB Compass

Databases数据库

A database is a container for collections. Each database gets its own set of files on the host file system. 数据库是集合的容器。每个数据库在主机文件系统上都有自己的一组文件。A single MongoDB server typically has multiple databases.一个MongoDB服务器通常有多个数据库。

Databases Tab数据库选项卡

The Databases tab lists the existing databases for your MongoDB deployment. “数据库”选项卡列出了MongoDB部署的现有数据库。To access the Databases tab, click the cluster name in the upper left corner and select the Databases tab.要访问“数据库”选项卡,请单击左上角的群集名称,然后选择“数据库”选项卡。

Database Tab

From this view, you can click a database name in the list to view its collections. Alternatively, you can view database collections by clicking the desired database in the left-hand navigation.在此视图中,可以单击列表中的数据库名称以查看其集合。或者,您可以通过单击左侧导航中所需的数据库来查看数据库集合。

You can also create or drop databases from this view.您也可以在此视图中创建删除数据库

Create a Database创建数据库

1

Click the Create Database button.单击“创建数据库”按钮。

From the Databases tab, click the Create Database button to bring up the Create Database dialog.在“数据库”选项卡中,单击“创建数据库”按钮以打开“创建数据库”对话框。

2

Enter database and first collection information.输入数据库和第一个集合信息。

In the dialog, enter the name of the database to create and its first collection. 在对话框中,输入要创建的数据库的名称及其第一个集合。Both the database name and the collection name are required.数据库名称和集合名称都是必需的。

If you want to create a capped collection, select the Capped Collection checkbox and enter the maximum bytes.如果要创建封顶集合,请选中“封顶集合”复选框并输入最大字节数。

If you want to use custom collation on the collection, select the Use Custom Collation checkbox and select the desired collation settings.如果要对集合使用自定义排序规则,请选中“使用自定义排序”复选框,然后选择所需的排序规则设置。

If your deployment is connected using In-Use Encryption, you can use Queryable Encryption on the newly created collection. 如果您的部署是使用“使用中的加密”连接的,则可以对新创建的集合使用可查询的加密Check the Queryable Encryption option and indicate the following encryption properties:选中“可查询加密”选项并指示以下加密属性:

3

Click Create Database to create the database and its first collection.单击“创建数据库”以创建数据库及其第一个集合。

Drop a Database删除数据库

1

Click the trash can icon for the database.单击数据库的垃圾桶图标。

From the Databases tab, to delete a database, click on the trash can icon for that database. 在数据库选项卡中,要删除数据库,请单击该数据库的垃圾桶图标。A confirmation dialog appears.此时会出现一个确认对话框。

2

Confirm the database to delete.确认要删除的数据库。

In the dialog, enter the name of the database to delete.在对话框中,输入要删除的数据库的名称。

3

Click Drop Database to delete the database.单击“删除数据库”以删除该数据库。

Limitations局限性

  • Creating and dropping databases is not permitted in MongoDB Compass Readonly Edition.“MongoDB Compass只读版”不允许创建和删除数据库。
  • Creating databases is not permitted if you are connected to a Data Lake.如果连接到数据湖,则不允许创建数据库。