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.

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.
Stap 2) Klik op Instellen
Once the download is complete, open the msi file. Click Next in the start-up screen.
Stap 3) Accepteer de licentieovereenkomst voor eindgebruikers
- Accepteer de licentieovereenkomst voor eindgebruikers.
- Klik op Volgende.
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.
Stap 5) Serviceconfiguratie
- Select โRun service as Network Service userโ. Make a note of the data directory; we will need this later.
- Klik op Volgende.
Stap 6) Start het installatieproces
Klik op de knop Installeren om de installatie te starten.
Step 7) Click Next once completed
Installation begins. Click Next once completed.
Stap 8) Klik op de knop Voltooien
Final step: once the installation is complete, click on the Finish button.
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.
Stap 2) Enter the following program into the shell:
var myMessage='Hello World'; printjson(myMessage);
Code Uitleg:
- We verklaren slechts een eenvoudige JavaScript variable to store a string called โHello Worldโ.
- 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:
- Full power of the Mongo shell
- Meerdere schelpen
- Meerdere resultaten
Stap 1) Ga naar uw link and click download.
Stap 2) Enter details in the popup and click submit.
Stap 3) Double click on the downloaded file.
Stap 4) Installation will auto-start.
Stap 5) Compass will launch with a Welcome screen.
Stap 6) Keep the privacy settings as default and click โStart Using Compassโ.
Stap 7) You will see the home screen with a list of current databases.
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:
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.
Code Uitleg:
- 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.
uitgang
Uit de uitvoer blijkt duidelijk dat er drie documenten zijn geรฏmporteerd MongoDB.
Exporteren MongoDB is done by using the mongoexport command.
Code Uitleg:
- We specificeren de db-optie om aan te geven uit welke database de gegevens moeten worden geรซxporteerd.
- 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.
- De vierde is om te specificeren welke velden van de collectie moeten worden geรซxporteerd.
- De optie โout specificeert de naam van het csv-bestand waarnaar de gegevens moeten worden geรซxporteerd.
uitgang
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.
- 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.
- De tweede optie is om te vermelden dat de locatie een bestand zal zijn.
- This mentions the location of the log file.
- 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.
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.
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.
- Voer persoonlijke gegevens in
- Akkoord met de voorwaarden
- Click the button โGet Started Freeโ
Stap 2) Click โBuild my first clusterโ.
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'.
Stap 4) Cluster creation takes some time.
Stap 5) After some time you will see the cluster ready.
Stap 6) Click Security > Add new user.
Stap 7) Op het volgende scherm:
- Voer gebruikersreferenties in
- Wijs rechten toe
- Click the Add User button
Stap 8) In the dashboard, click the connect button.
- Zet uw IP-verbinding op de witte lijst
- Kies de verbindingsmethode
Stap 9) Select the connection method of your choice to connect to the MongoDB server.


































