Steps and precautions for connecting to Mongodb database

(1) Open the bin installation directory of mongodb in the windows terminal

You can check the bin installation directory of mongobd in the folder first, and then copy the installation directory to the command line. For example, my installation directory is as shown in the figure:

 

 Enter in the command line: cd D:\My App\Mongodb\bin ( Note : If your mongodb is installed on the C drive, then just enter the above command directly, if not, then you need to enter your In the installed disk, for example, mine is installed on the D disk, so you need to enter: D: to enter the D disk before entering the above command)

Enter the bin directory of mongodb after entering the above command

(2) Create a folder as the mongodb database, ( note : the folder name can be chosen freely, but it is best to choose an English name and there should be no Chinese name or spaces in the folder path, for example: D:\My App\ db This is not allowed, because there are spaces in My App, bloody lesson, everyone must remember, woo woo woo) Mine is created on the desktop, as shown in the figure:

The path is as shown in the figure:

 

Copy the path of the created folder, and then enter the command in the terminal: mongod.exe --dbpath=C:\Users\your computer user account name\Desktop\db The message shown in the figure shows that mongodb has been The connection is successful

(3) Re-open another windows terminal and enter the bin directory of mongodb again

Enter the command: cd mongodb installation directory/bin

                   mongo.exe (enter the mongodb database)

When the interface description shown in the figure appears, you have successfully entered the Mongodb database, and then you can perform database operations, such as querying which databases are available: show dbs

 

( Note : Be sure not to close the first opened command terminal, because it is used to connect to the mongodb database. If you close it, the second command terminal will not be able to enter the mongodb database, let alone the mongodb database. Data additions, deletions, and changes)

 

That’s all for today, friends, keep going, if you think my article is helpful to you, please like it

 

 

 

 

Guess you like

Origin blog.csdn.net/m0_57206390/article/details/129876191