download

Open the website www.mongodb.com/try/downloa… Find the download interface as shown in the picture and select the version to download

The installation

Run the downloaded EXE file, automatic installation. The main window is displayed after the installation is complete.

Connect the mongo

The MongoDB service has no authentication by default and all clients can connect to it.

Once connected, you can see that there are three default databases

Creating a database

Click the plus button on the left

Enter the name of the database and the name of the set (here “set” meaning similar to MySQL table). Be sure to enter the name of the set. Otherwise, an error will be reported. This means that when you create a new database using Compass, you must specify a collection name.

Creating a Collection

Insert data

Select a Collection and click INSERT DOCUMENT

An ID value of type ObjectId is automatically generated

And then we can fill in the data as key-value pairs, which is basically JSON data

After the data is inserted, it can be seen in the collection. The default display is a JSON list

Toggle the TABLE button to present it as a database TABLE

Importing Data in Batches

Menu bar Collection → Import Data

Select Json file to import (the file name must be the same as the collection name)

Export data

  • Select an export mode (partial export, full export)

  • Select the field

  • Export file Format

  • Process results

Common mistakes

  • Start reporting JavaScript Error

Solution: End the process and start it again.

  • An error message is displayed indicating that the JSON format is incorrect

You can modify the file content according to the following rules: 1. 2. Unformatted JSON.

The following indicates two data files that can be imported

{"user_name":"Daisy"."user_gender":1}
{"user_name":"Bill"."user_gender":1}
Copy the code

If your data format looks like this: formatted JSON

{
    "user_name":"Daisy"."user_gender":1
}
{
    "user_name":"Zhang"."user_gender":1
}
Copy the code

Or multiple pieces of data in a row

{"user_name":"Daisy"."user_gender":1} {"user_name":"Bill"."user_gender":1}
Copy the code

Can’t be imported.