Hoe te downloaden en te installeren MongoDB on Windows en Wolk

โšก Slimme samenvatting

Hoe te downloaden en installeren MongoDB on Windows and Cloud is explained as a complete setup guide. This resource covers installing MongoDB Community Server on Windows Javascript, Python, and Ruby drivers, MongoDB Compass, configuration with import and export, a config file, and deploying MongoDB Atlas on the cloud.

  • ๐ŸชŸ Windows Installeren: Download the 64-bit Community Server and run the MSI installer.
  • ???? Drivers: JavaScript ships built in; add Python (pymongo) and Ruby (mongo) drivers.
  • ๐Ÿงญ Kompas: Installeer de MongoDB Compass GUI to manage databases visually.
  • โš™๏ธ Configuratie: Set the data directory, import/export CSV, and use a config file.
  • โ˜๏ธ Cloud: Implementeren MongoDB Atlas on AWS, Google Cloudof Azure and connect a client.

Hoe te downloaden en installeren MongoDB

De installateurs voor 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.

Hoe te downloaden en te installeren MongoDB on Windows

De volgende stappen kunnen worden gebruikt om te downloaden en te installeren MongoDB on Windows 10:

Stap 1) Downloaden MongoDB Community Server

Ga naar uw link en downloaden MongoDB Community Server. We zullen de 64-bitsversie installeren voor Windows.

Downloaden en installeren MongoDB on Windows

Stap 2) Klik op Instellen

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

Downloaden en installeren MongoDB on Windows

Stap 3) Accepteer de licentieovereenkomst voor eindgebruikers

  1. Accepteer de licentieovereenkomst voor eindgebruikers.
  2. Klik op Volgende.

Downloaden en installeren 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.

Downloaden en installeren MongoDB on Windows

Stap 5) Serviceconfiguratie

  1. Select โ€œRun service as Network Service userโ€. Make a note of the data directory; we will need this later.
  2. Klik op Volgende.

Downloaden en installeren MongoDB on Windows

Stap 6) Start het installatieproces

Klik op de knop Installeren om de installatie te starten.

Downloaden en installeren MongoDB on Windows

Step 7) Click Next once completed

Installation begins. Click Next once completed.

Downloaden en installeren MongoDB on Windows

Stap 8) Klik op de knop Voltooien

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

Downloaden en installeren MongoDB on Windows

Hallo Wereld MongoDB: JavaScriptstuurprogramma

Chauffeurs binnen MongoDB are used for connectivity between client applications and the database. For example, if you had a Java programma en vereist dat het verbinding maakt MongoDB, then you would require to download and integrate the Java driver zodat het programma kan werken met de MongoDB database.

De chauffeur voor JavaScript komt uit de doos. De MongoDB shell which is used to work with the MongoDB database is actually a JavaScript shell. To access it:

Stap 1) Go to โ€œC:\Program Files\MongoDB\Server\4.0\binโ€ en dubbelklik op mongo.exe. U kunt ook op de MongoDB desktop item.

Hallo Wereld MongoDB: JavaScriptstuurprogramma

Stap 2) Enter the following program into the shell:

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

Hallo Wereld MongoDB: JavaScriptstuurprogramma

Code Uitleg:

  1. We verklaren slechts een eenvoudige JavaScript variable to store a string called โ€˜Hello Worldโ€™.
  2. We gebruiken de printjson-methode om de variabele naar het scherm af te drukken.

Install Python bestuurder

Stap 1) Verzekeren Python is installed on the system.

Stap 2) Install the mongo related drivers by issuing the below command:

pip install pymongo

Installeer het Ruby-stuurprogramma

Stap 1) Ensure Ruby is installed on the system.

Stap 2) Ensure gems is updated by issuing the command:

gem update --system

Stap 3) Install the mongo related drivers by issuing the below command:

gem install mongo

Install MongoDB Compass - MongoDB Managementtool

Er zijn tools op de markt die dit kunnen beheren MongoDB. Een voorbeeld van zo'n niet-commercieel hulpmiddel is MongoDB Compass. Some of the features of Compass are given below:

  1. Full power of the Mongo shell
  2. Meerdere schelpen
  3. Meerdere resultaten

Stap 1) Ga naar uw link and click download.

Install MongoDB Compass

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

Install MongoDB Compass

Stap 3) Double click on the downloaded file.

Install MongoDB Compass

Stap 4) Installation will auto-start.

Install MongoDB Compass

Stap 5) Compass will launch with a Welcome screen.

Install MongoDB Compass

Stap 6) Keep the privacy settings as default and click โ€œStart Using Compassโ€.

Install MongoDB Compass

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

Install MongoDB Compass

MongoDB Configuratie, import en export

Voordat u het MongoDB server, het eerste belangrijke aspect is het configureren van de gegevensmap waar alle MongoDB data will be stored. This can be done in the following way:

MongoDB Configuratie, import en export

Het bovenstaande commando 'md \data\db' maakt een map met de naam \data\db op uw huidige locatie. MongoDB zal automatisch de databases op deze locatie aanmaken, omdat dit de standaardlocatie is MongoDB om zijn informatie op te slaan. We zorgen er alleen voor dat de directory aanwezig is, zodat MongoDB kan het vinden wanneer het begint.

Het importeren van gegevens in MongoDB wordt gedaan met de opdracht "mongoimport". Het volgende voorbeeld laat zien hoe dit kan worden gedaan.

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

Stap 2) Issue the mongoimport command.

MongoDB Configuratie, import en export

Code Uitleg:

  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.

uitgang

MongoDB Configuratie, import en export

Uit de uitvoer blijkt duidelijk dat er drie documenten zijn geรฏmporteerd MongoDB.

Exporteren MongoDB is done by using the mongoexport command.

MongoDB Configuratie, import en export

Code Uitleg:

  1. We specificeren de db-optie om aan te geven uit welke database de gegevens moeten worden geรซxporteerd.
  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. De vierde is om te specificeren welke velden van de collectie moeten worden geรซxporteerd.
  5. De optie โ€“out specificeert de naam van het csv-bestand waarnaar de gegevens moeten worden geรซxporteerd.

uitgang

MongoDB Configuratie, import en export

Uit de uitvoer blijkt duidelijk dat er drie records zijn geรซxporteerd MongoDB.

configureren MongoDB server met configuratiebestand

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:

Stap 1) Create a file called โ€œmongod.confโ€ and store the below information in the file.

configureren MongoDB Server met configuratiebestand

  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. De tweede optie is om te vermelden dat de locatie een bestand zal zijn.
  3. This mentions the location of the log file.
  4. De logAppend: โ€œtrueโ€ betekent ervoor zorgen dat de loginformatie steeds aan het logbestand wordt toegevoegd. Als u de waarde op โ€œfalseโ€ zet, wordt het bestand verwijderd en opnieuw aangemaakt zodra de server opnieuw opstart.

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

configureren MongoDB Server met configuratiebestand

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.

configureren MongoDB Server met configuratiebestand

Hoe te installeren MongoDB in de cloud (AWS, Google, Azure)

You do not need to install the MongoDB server and configure it. You can deploy a MongoDB Atlas-server in de cloud op platforms zoals AWS, Google Clouden Azure, and connect to the instance using a client. Below are the detailed steps:

Stap 1) Ga naar uw link.

  1. Voer persoonlijke gegevens in
  2. Akkoord met de voorwaarden
  3. Click the button โ€œGet Started Freeโ€

Install MongoDB op Wolk

Stap 2) Click โ€œBuild my first clusterโ€.

Install MongoDB op Wolk

Stap 3) U kunt kiezen tussen: AWS, Google Clouden 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'.

Install MongoDB op Wolk

Stap 4) Cluster creation takes some time.

Install MongoDB op Wolk

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

Install MongoDB op Wolk

Stap 6) Click Security > Add new user.

Install MongoDB op Wolk

Stap 7) Op het volgende scherm:

  1. Voer gebruikersreferenties in
  2. Wijs rechten toe
  3. Click the Add User button

Install MongoDB op Wolk

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

  1. Zet uw IP-verbinding op de witte lijst
  2. Kies de verbindingsmethode

Install MongoDB op Wolk

Stap 9) Select the connection method of your choice to connect to the MongoDB server.

Install MongoDB op Wolk

Veelgestelde vragen

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.

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

Ja. MongoDB Community Server is free and open source for Windows, macOSen 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 Cloudof Azure.

Vat dit bericht samen met: