Cum se descarcă și se instalează MongoDB on Windows și Cloud
⚡ Rezumat inteligent
Cum se descarcă și se instalează MongoDB on Windows and Cloud is explained as a complete setup guide. This resource covers installing MongoDB Community Server on Windows, Javascenariu, Python, and Ruby drivers, MongoDB Compass, configuration with import and export, a config file, and deploying MongoDB Atlas on the cloud.

Instalatorii pentru MongoDB are available in both the 32-bit and 64-bit format. The 32-bit installers are good for development and test environments. But for production environments you should use the 64-bit installers. Otherwise, you can be limited in the amount of data that can be stored within MongoDB. It is advisable to always use the stable release for production environments.
Cum se descarcă și se instalează MongoDB on Windows
Următorii pași pot fi utilizați pentru descărcare și instalare MongoDB on Windows 10:
Pasul 1) Descărcați MongoDB Server comunitar
Du-te la legătură și descărcare MongoDB Server comunitar. Vom instala versiunea pe 64 de biți pt Windows.
Pasul 2) Faceți clic pe Configurare
Once the download is complete, open the msi file. Click Next in the start-up screen.
Pasul 3) Acceptați acordul de licență pentru utilizatorul final
- Acceptați acordul de licență pentru utilizatorul final.
- Faceți clic pe Următorul.
Step 4) Click on the “Complete” button
Click on the “Complete” button to install all of the components. The custom option can be used to install selective components or if you want to change the location of the installation.
Pasul 5) Configurarea serviciului
- Select “Run service as Network Service user”. Make a note of the data directory; we will need this later.
- Faceți clic pe Următorul.
Pasul 6) Începeți procesul de instalare
Faceți clic pe butonul Instalare pentru a începe instalarea.
Step 7) Click Next once completed
Installation begins. Click Next once completed.
Pasul 8) Faceți clic pe butonul Terminare
Final step: once the installation is complete, click on the Finish button.
Salut Lume MongoDB: JavaDriver de script
Șoferii în MongoDB are used for connectivity between client applications and the database. For example, if you had a Java program și i-a cerut să se conecteze la MongoDB, then you would require to download and integrate the Java driver, astfel încât programul să poată funcționa cu MongoDB Bază de date.
Șoferul pentru JavaScenariu iese din cutie. The MongoDB shell which is used to work with the MongoDB baza de date este de fapt a JavaScript shell. To access it:
Pas 1) Go to “C:\Program Files\MongoDB\Server\4.0\bin” și faceți dublu clic pe mongo.exe. Alternativ, puteți, de asemenea, să faceți clic pe MongoDB desktop item.
Pas 2) Enter the following program into the shell:
var myMessage='Hello World'; printjson(myMessage);
Code Explicaţie:
- Declarăm doar un simplu JavaScript variable to store a string called ‘Hello World’.
- Folosim metoda printjson pentru a imprima variabila pe ecran.
Instalare Python Şofer
Pas 1) Asigura Python is installed on the system.
Pas 2) Install the mongo related drivers by issuing the below command:
pip install pymongo
Instalați driverul Ruby
Pas 1) Ensure Ruby is installed on the system.
Pas 2) Ensure gems is updated by issuing the command:
gem update --system
Pas 3) Install the mongo related drivers by issuing the below command:
gem install mongo
Instalare MongoDB Compass - MongoDB Instrument de management
Există instrumente pe piață care sunt disponibile pentru administrare MongoDB. Un astfel de instrument necomercial este MongoDB Compass. Some of the features of Compass are given below:
- Full power of the Mongo shell
- Mai multe scoici
- Rezultate multiple
Pas 1) Du-te la legătură și faceți clic pe descărcare.
Pas 2) Enter details in the popup and click submit.
Pas 3) Double click on the downloaded file.
Pas 4) Installation will auto-start.
Pas 5) Compass will launch with a Welcome screen.
Pas 6) Keep the privacy settings as default and click “Start Using Compass”.
Pas 7) You will see the home screen with a list of current databases.
MongoDB Configurare, import și export
Înainte de a începe MongoDB server, primul aspect cheie este configurarea directorului de date în care sunt toate MongoDB data will be stored. This can be done in the following way:
Comanda de mai sus „md \data\db” face un director numit \data\db în locația dvs. curentă. MongoDB va crea automat bazele de date în această locație, deoarece aceasta este locația implicită pentru MongoDB pentru a-și stoca informațiile. Ne asigurăm doar că directorul este prezent, astfel încât MongoDB îl pot găsi când pornește.
Importul de date în MongoDB se face folosind comanda „mongoimport”. Următorul exemplu arată cum se poate face acest lucru.
Pas 1) Create a CSV file called data.csv and put the following data in it:
Employeeid,EmployeeName 1,Guru99 2,Mohan 3,Smith
So in the above example, we are assuming we want to import 3 documents into a collection called data. The first row is called the header line, which will become the field names of the collection.
Pas 2) Issue the mongoimport command.
Code Explicaţie:
- We are specifying the db option to say which database the data should be imported to.
- The type option is to specify that we are importing a csv file.
- Remember that the first row is called the header line, which will become the field names of the collection; that is why we specify the –headerline option. And then we specify our data.csv file.
producție
Rezultatul arată clar că 3 documente au fost importate în MongoDB.
Exportarea MongoDB is done by using the mongoexport command.
Code Explicaţie:
- Specificăm opțiunea db pentru a spune din ce bază de date ar trebui să fie exportate datele.
- We are specifying the collection option to say which collection to use.
- The third option is to specify that we want to export to a csv file.
- Al patrulea este de a specifica ce câmpuri ale colecției trebuie exportate.
- Opțiunea –out specifică numele fișierului csv în care să exporte datele.
producție
Rezultatul arată clar că 3 înregistrări au fost exportate din MongoDB.
Configurarea MongoDB server cu fișier de configurare
One can configure the mongod server instance to start up with a configuration file. The configuration file contains settings that are equivalent to the mongod command-line options. For example, suppose you wanted MongoDB to store all its logging information to a custom location, then follow the below steps:
Pas 1) Create a file called “mongod.conf” and store the below information in the file.
- The first line of the file specifies that we want to add configuration for the system log file, that is where the information about what the server is doing goes, in a custom log file.
- A doua opțiune este să menționăm că locația va fi un fișier.
- This mentions the location of the log file.
- LogAppend: „adevărat” înseamnă să vă asigurați că informațiile de jurnal continuă să fie adăugate la fișierul jurnal. Dacă puneți valoarea ca „fals”, atunci fișierul va fi șters și creat proaspăt ori de câte ori serverul pornește din nou.
Pas 2) Start the mongod server process and specify the above created configuration file as a parameter. The screenshot of how this can be done is shown below.
Once the above command is executed, the server process will start using this configuration file, and if you go to the /etc directory on your system, you will see the mongod.log file created. The below snapshot shows an example of what a log file would look like.
Cum se instalează MongoDB în cloud (AWS, Google, Azure)
You do not need to install the MongoDB server and configure it. You can deploy a MongoDB Server Atlas pe cloud pe platforme precum AWS, Google Cloud și Azure, and connect to the instance using a client. Below are the detailed steps:
Pas 1) Du-te la legătură.
- Introduceți detaliile personale
- Ești de acord cu termenii? Sunteți de acord cu termenii
- Click the button “Get Started Free”
Pas 2) Click “Build my first cluster”.
Pas 3) Puteți alege între AWS, Google Cloud și Azure as your cloud provider. In this tutorial, we will use AWS, which is set by default. Make no other changes on the page and click “Create Cluster".
Pas 4) Cluster creation takes some time.
Pas 5) After some time you will see the cluster ready.
Pas 6) Click Security > Add new user.
Pas 7) Pe ecranul următor:
- Introduceți acreditările utilizatorului
- Atribuiți privilegii
- Faceți clic pe butonul Adăugați utilizator
Pas 8) In the dashboard, click the connect button.
- Lista albă a conexiunii dvs. IP
- Alegeți metoda de conectare
Pas 9) Select the connection method of your choice to connect to the MongoDB Server.


































