官术网_书友最值得收藏!

  • MongoDB 4 Quick Start Guide
  • Doug Bierer
  • 235字
  • 2021-08-13 15:25:04

Creating a MongoDB database and collection

It is now time to put into practice how to create a MongoDB database and collection. The Chapter 3, Using the MongoDB Shell, will show you how to perform operations using the MongoDB shell. For the purposes of this introductory chapter we will use MongoDB Compass (https://www.mongodb.com/products/compass), which is a free graphical utility you can use to perform administration.

To create a MongoDB database and start a collection using MongoDB Compass, proceed as follows:

  1. Open MongoDB Compass using the link as appropriate to your operating system. In this illustration we are using Ubuntu Linux, so we launch using the GUI.
  2. Click on the plus sign (+) to create a database:
  3. When the Create Database dialog box appears, enter the name of the database and the name of the first collection. When first creating a database, you cannot have one without the other. For this illustration, the database will be sweetscomplete and the first collection will be customers:

Congratulations! The database has now been created! If you click on its name in MongoDB Compass, you will see the newly created collection as well:

Consider jumping ahead to the Simple Backup and Restore topic in Chapter 6, Maintaining MongoDB Performance, in this book for a discussion on how to restore data. In the source code repository for this book, you will find a backup of sample data used in subsequent examples.
主站蜘蛛池模板: 沅江市| 崇义县| 福鼎市| 沙河市| 曲沃县| 虞城县| 呼和浩特市| 大关县| 故城县| 北流市| 榆林市| 鹤峰县| 巩义市| 抚宁县| 郁南县| 麟游县| 建宁县| 酉阳| 德庆县| 南郑县| 巴楚县| 郁南县| 防城港市| 平泉县| 永兴县| 广饶县| 确山县| 迭部县| 崇义县| 上栗县| 五华县| 林芝县| 同心县| 枞阳县| 乌拉特后旗| 东丽区| 祁门县| 当雄县| 嘉峪关市| 上饶县| 佳木斯市|