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.

  • 🪟 Windows Instalați: Download the 64-bit Community Server and run the MSI installer.
  • 🔌 drivere: JavaScript ships built in; add Python (pymongo) and Ruby (mongo) drivers.
  • 🧭 Busolă: instalaţi MongoDB Compass GUI to manage databases visually.
  • ⚙️ Configurare: Set the data directory, import/export CSV, and use a config file.
  • ☁️ Cloud: Lansa MongoDB Atlas on AWS, Google Cloud, Azure and connect a client.

Cum se descarcă și se instalează MongoDB

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.

Descărcați și instalați MongoDB on Windows

Pasul 2) Faceți clic pe Configurare

Once the download is complete, open the msi file. Click Next in the start-up screen.

Descărcați și instalați MongoDB on Windows

Pasul 3) Acceptați acordul de licență pentru utilizatorul final

  1. Acceptați acordul de licență pentru utilizatorul final.
  2. Faceți clic pe Următorul.

Descărcați și instalați MongoDB on Windows

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.

Descărcați și instalați MongoDB on Windows

Pasul 5) Configurarea serviciului

  1. Select “Run service as Network Service user”. Make a note of the data directory; we will need this later.
  2. Faceți clic pe Următorul.

Descărcați și instalați MongoDB on Windows

Pasul 6) Începeți procesul de instalare

Faceți clic pe butonul Instalare pentru a începe instalarea.

Descărcați și instalați MongoDB on Windows

Step 7) Click Next once completed

Installation begins. Click Next once completed.

Descărcați și instalați MongoDB on Windows

Pasul 8) Faceți clic pe butonul Terminare

Final step: once the installation is complete, click on the Finish button.

Descărcați și instalați MongoDB on Windows

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.

Salut Lume MongoDB: JavaDriver de script

Pas 2) Enter the following program into the shell:

var myMessage='Hello World';
printjson(myMessage);

Salut Lume MongoDB: JavaDriver de script

Code Explicaţie:

  1. Declarăm doar un simplu JavaScript variable to store a string called ‘Hello World’.
  2. 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:

  1. Full power of the Mongo shell
  2. Mai multe scoici
  3. Rezultate multiple

Pas 1) Du-te la legătură și faceți clic pe descărcare.

Instalare MongoDB Compass

Pas 2) Enter details in the popup and click submit.

Instalare MongoDB Compass

Pas 3) Double click on the downloaded file.

Instalare MongoDB Compass

Pas 4) Installation will auto-start.

Instalare MongoDB Compass

Pas 5) Compass will launch with a Welcome screen.

Instalare MongoDB Compass

Pas 6) Keep the privacy settings as default and click “Start Using Compass”.

Instalare MongoDB Compass

Pas 7) You will see the home screen with a list of current databases.

Instalare MongoDB Compass

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:

MongoDB Configurare, import și export

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.

MongoDB Configurare, import și export

Code Explicaţie:

  1. We are specifying the db option to say which database the data should be imported to.
  2. The type option is to specify that we are importing a csv file.
  3. 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

MongoDB Configurare, import și export

Rezultatul arată clar că 3 documente au fost importate în MongoDB.

Exportarea MongoDB is done by using the mongoexport command.

MongoDB Configurare, import și export

Code Explicaţie:

  1. Specificăm opțiunea db pentru a spune din ce bază de date ar trebui să fie exportate datele.
  2. We are specifying the collection option to say which collection to use.
  3. The third option is to specify that we want to export to a csv file.
  4. Al patrulea este de a specifica ce câmpuri ale colecției trebuie exportate.
  5. Opțiunea –out specifică numele fișierului csv în care să exporte datele.

producție

MongoDB Configurare, import și export

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.

Configurarea MongoDB Server cu fișier de configurare

  1. 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.
  2. A doua opțiune este să menționăm că locația va fi un fișier.
  3. This mentions the location of the log file.
  4. 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.

Configurarea MongoDB Server cu fișier de configurare

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.

Configurarea MongoDB Server cu fișier de configurare

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ă.

  1. Introduceți detaliile personale
  2. Ești de acord cu termenii? Sunteți de acord cu termenii
  3. Click the button “Get Started Free”

Instalare MongoDB pe Cloud

Pas 2) Click “Build my first cluster”.

Instalare MongoDB pe Cloud

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".

Instalare MongoDB pe Cloud

Pas 4) Cluster creation takes some time.

Instalare MongoDB pe Cloud

Pas 5) After some time you will see the cluster ready.

Instalare MongoDB pe Cloud

Pas 6) Click Security > Add new user.

Instalare MongoDB pe Cloud

Pas 7) Pe ecranul următor:

  1. Introduceți acreditările utilizatorului
  2. Atribuiți privilegii
  3. Faceți clic pe butonul Adăugați utilizator

Instalare MongoDB pe Cloud

Pas 8) In the dashboard, click the connect button.

  1. Lista albă a conexiunii dvs. IP
  2. Alegeți metoda de conectare

Instalare MongoDB pe Cloud

Pas 9) Select the connection method of your choice to connect to the MongoDB Server.

Instalare MongoDB pe Cloud

Întrebări frecvente

Yes. AI assistants can generate mongod configuration files, explain connection errors, and suggest fixes for driver or service issues. You should still verify commands against the official MongoDB documentation before applying them.

Da. MongoDB Atlas includes Atlas Vector Search and AI integrations that let you build semantic search and retrieval-augmented generation apps. It stores embeddings alongside documents, removing the need for a separate vector database.

Da. MongoDB Community Server is free and open source for Windows, macOSși Linux. MongoDB Atlas also provides a free cloud tier, while Enterprise Edition adds paid advanced features and support.

Community Server is installed and managed on your own machine or server. Atlas is a fully managed cloud service that handles setup, scaling, backups, and security on AWS, Google Cloud, Azure.

Rezumați această postare cu: