Jak stáhnout a nainstalovat MongoDB on Windows a Cloud
⚡ Chytré shrnutí
Jak stáhnout a nainstalovat MongoDB on Windows and Cloud is explained as a complete setup guide. This resource covers installing MongoDB Community Server on Windowsse JavaSkript, Python, and Ruby drivers, MongoDB Compass, configuration with import and export, a config file, and deploying MongoDB Atlas on the cloud.

Instalatéři pro 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.
Jak stáhnout a nainstalovat MongoDB on Windows
Ke stažení a instalaci lze použít následující kroky MongoDB on Windows 10:
Krok 1) Stáhnout MongoDB Community Server
Přejít na https://trials.autocruitment.com a stáhnout MongoDB komunitní server. Nainstalujeme 64bitovou verzi pro Windows.
Krok 2) Klikněte na Nastavení
Once the download is complete, open the msi file. Click Next in the start-up screen.
Krok 3) Přijměte licenční smlouvu s koncovým uživatelem
- Accept the End-User License Agreement.
- Klepněte na tlačítko Další.
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.
Krok 5) Konfigurace služby
- Select “Run service as Network Service user”. Make a note of the data directory; we will need this later.
- Klepněte na tlačítko Další.
Krok 6) Spusťte proces instalace
Klepnutím na tlačítko Instalovat spustíte instalaci.
Step 7) Click Next once completed
Installation begins. Click Next once completed.
Krok 8) Klikněte na tlačítko Dokončit
Final step: once the installation is complete, click on the Finish button.
Ahoj světe MongoDB: JavaOvladač skriptu
Řidiči v MongoDB are used for connectivity between client applications and the database. For example, if you had a Java program a vyžadoval, aby se k němu připojil MongoDB, then you would require to download and integrate the Java ovladač, aby program mohl pracovat s MongoDB databáze.
Řidič pro JavaScénář vychází z krabice. The MongoDB shell which is used to work with the MongoDB database is actually a JavaScript shell. To access it:
Krok 1) Go to “C:\Program Files\MongoDB\Server\4.0\bin“ a dvakrát klikněte na mongo.exe. Případně můžete také kliknout na MongoDB desktop item.
Krok 2) Enter the following program into the shell:
var myMessage='Hello World'; printjson(myMessage);
Code Vysvětlení:
- Právě prohlašujeme jednoduché JavaScript variable to store a string called ‘Hello World’.
- Pro tisk proměnné na obrazovku používáme metodu printjson.
instalovat Python Řidič
Krok 1) Zajistit Python is installed on the system.
Krok 2) Install the mongo related drivers by issuing the below command:
pip install pymongo
Nainstalujte ovladač Ruby
Krok 1) Ensure Ruby is installed on the system.
Krok 2) Ensure gems is updated by issuing the command:
gem update --system
Krok 3) Install the mongo related drivers by issuing the below command:
gem install mongo
instalovat MongoDB Compass - MongoDB Nástroj pro správu
Na trhu existují nástroje, které jsou k dispozici pro správu MongoDB. Jedním z takových nekomerčních nástrojů je MongoDB Compass. Some of the features of Compass are given below:
- Full power of the Mongo shell
- Více skořápek
- Více výsledků
Krok 1) Přejít na https://trials.autocruitment.com and click download.
Krok 2) Enter details in the popup and click submit.
Krok 3) Double click on the downloaded file.
Krok 4) Installation will auto-start.
Krok 5) Compass will launch with a Welcome screen.
Krok 6) Keep the privacy settings as default and click “Start Using Compass”.
Krok 7) You will see the home screen with a list of current databases.
MongoDB Konfigurace, import a export
Před spuštěním MongoDB server, prvním klíčovým aspektem je konfigurace datového adresáře, kde jsou všechny MongoDB data will be stored. This can be done in the following way:
Výše uvedený příkaz 'md \data\db' vytvoří adresář s názvem \data\db ve vašem aktuálním umístění. MongoDB automaticky vytvoří databáze v tomto umístění, protože toto je výchozí umístění MongoDB k uložení jeho informací. Zajišťujeme pouze přítomnost adresáře, takže MongoDB můžete to najít, když to začne.
Import dat do MongoDB se provádí pomocí příkazu „mongoimport“. Následující příklad ukazuje, jak to lze provést.
Krok 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.
Krok 2) Issue the mongoimport command.
Code Vysvětlení:
- 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.
Výstup
Výstup jasně ukazuje, že byly importovány 3 dokumenty MongoDB.
Export MongoDB is done by using the mongoexport command.
Code Vysvětlení:
- Uvádíme volbu db, abychom řekli, ze které databáze mají být data exportována.
- 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.
- Čtvrtým je specifikovat, která pole kolekce mají být exportována.
- Možnost –out určuje název souboru csv, do kterého se mají data exportovat.
Výstup
Výstup jasně ukazuje, že byly exportovány 3 záznamy z MongoDB.
Konfigurace MongoDB server s konfiguračním souborem
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:
Krok 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.
- Druhou možností je zmínit, že umístěním bude soubor.
- This mentions the location of the log file.
- LogAppend: „true“ znamená zajistit, aby se informace protokolu neustále přidávaly do souboru protokolu. Pokud zadáte hodnotu „false“, soubor bude smazán a vytvořen jako nový, kdykoli se server znovu spustí.
Krok 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.
Jak nainstalovat MongoDB v cloudu (AWS, Google, Azure)
You do not need to install the MongoDB server and configure it. You can deploy a MongoDB Server Atlas v cloudu na platformách jako AWS, Google Cloud, a Azure, and connect to the instance using a client. Below are the detailed steps:
Krok 1) Přejít na https://trials.autocruitment.com.
- Zadejte osobní údaje
- Souhlasíš s podmínkami
- Click the button “Get Started Free”
Krok 2) Click “Build my first cluster”.
Krok 3) Můžete si vybrat mezi AWS, Google Cloud, a 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".
Krok 4) Cluster creation takes some time.
Krok 5) After some time you will see the cluster ready.
Krok 6) Click Security > Add new user.
Krok 7) Na další obrazovce:
- Zadejte přihlašovací údaje uživatele
- Přidělte oprávnění
- Click the Add User button
Krok 8) In the dashboard, click the connect button.
- Seznam povolených připojení IP
- Vyberte způsob připojení
Krok 9) Select the connection method of your choice to connect to the MongoDB serveru.


































