Jak pobrać i zainstalować MongoDB on Windows i Chmura
⚡ Inteligentne podsumowanie
Jak pobrać i zainstalować MongoDB on Windows and Cloud is explained as a complete setup guide. This resource covers installing MongoDB Community Server on WindowsThe Javascenariusz, Python, and Ruby drivers, MongoDB Compass, configuration with import and export, a config file, and deploying MongoDB Atlas on the cloud.

Instalatorzy ds 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 pobrać i zainstalować MongoDB on Windows
Aby pobrać i zainstalować program, wykonaj następujące czynności: MongoDB on Windows 10:
Krok 1) Pobierz MongoDB Community Server
Przejdź do link I pobierz MongoDB Serwer społecznościowy. Zainstalujemy wersję 64-bitową dla Windows.
Krok 2) Kliknij opcję Konfiguracja
Once the download is complete, open the msi file. Click Next in the start-up screen.
Krok 3) Zaakceptuj Umowę licencyjną użytkownika końcowego
- Accept the End-User License Agreement.
- Kliknij Następny.
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) Konfiguracja usługi
- Select “Run service as Network Service user”. Make a note of the data directory; we will need this later.
- Kliknij Następny.
Krok 6) Rozpocznij proces instalacji
Kliknij przycisk Instaluj, aby rozpocząć instalację.
Step 7) Click Next once completed
Installation begins. Click Next once completed.
Krok 8) Kliknij przycisk Zakończ
Final step: once the installation is complete, click on the Finish button.
Witaj świecie MongoDB: JavaSterownik skryptu
Kierowcy w MongoDB are used for connectivity between client applications and the database. For example, if you had a Java program i wymagał połączenia z nim MongoDB, then you would require to download and integrate the Java sterownik, aby program mógł współpracować z MongoDB Baza danych.
Kierowca za JAVASCRIPT wychodzi z pudełka. 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” i kliknij dwukrotnie na mongo.exe. Alternatywnie możesz również kliknąć na MongoDB desktop item.
Krok 2) Enter the following program into the shell:
var myMessage='Hello World'; printjson(myMessage);
Code Wyjaśnienie:
- Po prostu deklarujemy prostotę JavaScript variable to store a string called ‘Hello World’.
- Do wydrukowania zmiennej na ekranie używamy metody printjson.
Zainstalować Python Kierowca
Krok 1) Zapewniać Python is installed on the system.
Krok 2) Install the mongo related drivers by issuing the below command:
pip install pymongo
Zainstaluj sterownik 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
Zainstalować MongoDB Compass - MongoDB Narzędzie zarządzania
Na rynku dostępne są narzędzia umożliwiające zarządzanie MongoDB. Jednym z takich niekomercyjnych narzędzi jest MongoDB Compass. Some of the features of Compass are given below:
- Full power of the Mongo shell
- Wiele skorup
- Wiele wyników
Krok 1) Przejdź do link 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 Konfiguracja, import i eksport
Przed uruchomieniem MongoDB serwerze, pierwszym kluczowym aspektem jest skonfigurowanie katalogu danych, w którym znajdują się wszystkie pliki MongoDB data will be stored. This can be done in the following way:
Powyższe polecenie 'md \data\db' tworzy katalog o nazwie \data\db w Twojej bieżącej lokalizacji. MongoDB automatycznie utworzy bazy danych w tej lokalizacji, ponieważ jest to domyślna lokalizacja dla MongoDB do przechowywania jego informacji. Po prostu upewniamy się, że katalog jest obecny, więc tak MongoDB można go znaleźć, kiedy się zacznie.
Import danych do MongoDB odbywa się za pomocą polecenia „mongoimport”. Poniższy przykład pokazuje, jak to zrobić.
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 Wyjaśnienie:
- 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.
Wydajność
Dane wyjściowe wyraźnie wskazują, że do programu zaimportowano 3 dokumenty MongoDB.
Eksportowanie MongoDB is done by using the mongoexport command.
Code Wyjaśnienie:
- Określamy opcję db, aby określić, z której bazy danych mają zostać wyeksportowane dane.
- 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.
- Czwartym jest określenie, które pola kolekcji mają zostać wyeksportowane.
- Opcja –out określa nazwę pliku CSV, do którego mają zostać wyeksportowane dane.
Wydajność
Dane wyjściowe wyraźnie pokazują, że wyeksportowano 3 rekordy MongoDB.
Konfigurowanie MongoDB serwer z plikiem konfiguracyjnym
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.
- Drugą opcją jest wspomnienie, że lokalizacją będzie plik.
- This mentions the location of the log file.
- LogAppend: „true” oznacza, że informacje dziennika będą stale dodawane do pliku dziennika. Jeśli ustawisz wartość jako „false”, plik zostanie usunięty i utworzony na nowo przy każdym ponownym uruchomieniu serwera.
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 zainstalować MongoDB w chmurze (AWS, Google, Azure)
You do not need to install the MongoDB server and configure it. You can deploy a MongoDB Serwer Atlas w chmurze na platformach takich jak AWS, Google Cloud, Azure, and connect to the instance using a client. Below are the detailed steps:
Krok 1) Przejdź do link.
- Wprowadź dane osobowe
- Zgadzasz się na warunki
- Click the button “Get Started Free”
Krok 2) Click “Build my first cluster”.
Krok 3) Możesz wybrać pomiędzy AWS, Google Cloud, 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 następnym ekranie:
- Wprowadź poświadczenia użytkownika
- Przypisz uprawnienia
- Click the Add User button
Krok 8) In the dashboard, click the connect button.
- Dodaj do białej listy swoje połączenie IP
- Wybierz metodę połączenia
Krok 9) Select the connection method of your choice to connect to the MongoDB serwer.


































