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.

  • 🪟 Windows Zainstaluj: Download the 64-bit Community Server and run the MSI installer.
  • 🔌 sterowniki: JavaScript ships built in; add Python (pymongo) and Ruby (mongo) drivers.
  • 🧭 Kompas: Instalacja MongoDB Compass GUI to manage databases visually.
  • ⚙️ Konfiguracja: Set the data directory, import/export CSV, and use a config file.
  • ☁️. Chmura: Rozmieścić MongoDB Atlas on AWS, Google Cloudlub Azure and connect a client.

Jak pobrać i zainstalować MongoDB

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.

Pobierz i zainstaluj MongoDB on Windows

Krok 2) Kliknij opcję Konfiguracja

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

Pobierz i zainstaluj MongoDB on Windows

Krok 3) Zaakceptuj Umowę licencyjną użytkownika końcowego

  1. Accept the End-User License Agreement.
  2. Kliknij Następny.

Pobierz i zainstaluj 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.

Pobierz i zainstaluj MongoDB on Windows

Krok 5) Konfiguracja usługi

  1. Select “Run service as Network Service user”. Make a note of the data directory; we will need this later.
  2. Kliknij Następny.

Pobierz i zainstaluj MongoDB on Windows

Krok 6) Rozpocznij proces instalacji

Kliknij przycisk Instaluj, aby rozpocząć instalację.

Pobierz i zainstaluj MongoDB on Windows

Step 7) Click Next once completed

Installation begins. Click Next once completed.

Pobierz i zainstaluj MongoDB on Windows

Krok 8) Kliknij przycisk Zakończ

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

Pobierz i zainstaluj MongoDB on Windows

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.

Witaj świecie MongoDB: JavaSterownik skryptu

Krok 2) Enter the following program into the shell:

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

Witaj świecie MongoDB: JavaSterownik skryptu

Code Wyjaśnienie:

  1. Po prostu deklarujemy prostotę JavaScript variable to store a string called ‘Hello World’.
  2. 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:

  1. Full power of the Mongo shell
  2. Wiele skorup
  3. Wiele wyników

Krok 1) Przejdź do link and click download.

Zainstalować MongoDB Compass

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

Zainstalować MongoDB Compass

Krok 3) Double click on the downloaded file.

Zainstalować MongoDB Compass

Krok 4) Installation will auto-start.

Zainstalować MongoDB Compass

Krok 5) Compass will launch with a Welcome screen.

Zainstalować MongoDB Compass

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

Zainstalować MongoDB Compass

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

Zainstalować MongoDB Compass

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:

MongoDB Konfiguracja, import i eksport

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.

MongoDB Konfiguracja, import i eksport

Code Wyjaśnienie:

  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.

Wydajność

MongoDB Konfiguracja, import i eksport

Dane wyjściowe wyraźnie wskazują, że do programu zaimportowano 3 dokumenty MongoDB.

Eksportowanie MongoDB is done by using the mongoexport command.

MongoDB Konfiguracja, import i eksport

Code Wyjaśnienie:

  1. Określamy opcję db, aby określić, z której bazy danych mają zostać wyeksportowane dane.
  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. Czwartym jest określenie, które pola kolekcji mają zostać wyeksportowane.
  5. Opcja –out określa nazwę pliku CSV, do którego mają zostać wyeksportowane dane.

Wydajność

MongoDB Konfiguracja, import i eksport

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.

Konfigurowanie MongoDB Serwer z plikiem konfiguracyjnym

  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. Drugą opcją jest wspomnienie, że lokalizacją będzie plik.
  3. This mentions the location of the log file.
  4. 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.

Konfigurowanie MongoDB Serwer z plikiem konfiguracyjnym

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.

Konfigurowanie MongoDB Serwer z plikiem konfiguracyjnym

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.

  1. Wprowadź dane osobowe
  2. Zgadzasz się na warunki
  3. Click the button “Get Started Free”

Zainstalować MongoDB w chmurze

Krok 2) Click “Build my first cluster”.

Zainstalować MongoDB w chmurze

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

Zainstalować MongoDB w chmurze

Krok 4) Cluster creation takes some time.

Zainstalować MongoDB w chmurze

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

Zainstalować MongoDB w chmurze

Krok 6) Click Security > Add new user.

Zainstalować MongoDB w chmurze

Krok 7) Na następnym ekranie:

  1. Wprowadź poświadczenia użytkownika
  2. Przypisz uprawnienia
  3. Click the Add User button

Zainstalować MongoDB w chmurze

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

  1. Dodaj do białej listy swoje połączenie IP
  2. Wybierz metodę połączenia

Zainstalować MongoDB w chmurze

Krok 9) Select the connection method of your choice to connect to the MongoDB serwer.

Zainstalować MongoDB w chmurze

FAQ

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.

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

Tak. MongoDB Community Server is free and open source for Windows, macOSi 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 Cloudlub Azure.

Podsumuj ten post następująco: