How to Install MongoDB Community Edition 6.0.5 on Ubuntu 22.04?
MongoDB Community Edition is an open-source documents-oriented database. In Ubuntu 22.04, follow these steps to install the MongoDB Community Edition 6.0.5:
Step 1: Import the MongoDB GPG key
In Ubuntu 22.04, right-click and select the option “Open in Terminal”:
The gnupg package is already installed in Ubuntu. In case it is not installed then install the key management system by executing the given below command:
Output
The GnuPG is successfully installed in Ubuntu 22.04.
To import the MongoDB key from the official website, use the command provided below:
sudo gpg -o /usr/share/keyrings/mongodb-server-6.0.gpg \
--dearmor
Output
The MongoDB GPG key was imported successfully.
Step 2: Create a List File to Import the MongoDB Repository
After importing the MongoDB GPG key, run this command to create a file “mongodb-org-6.0.list” in “source.list.d” directory to import the MongoDB repository:
Output
The output returned a message after adding the MongoDB repositories in Ubuntu 22.04.
Step 3: Update the Package Lists
The next step is to update the package lists after adding the key and repository of Ubuntu 22.04 by running the below command:
Output
The package lists updated successfully in Ubuntu.
Step 4: Install the 6.0.5 Edition in MongoDB Community
The user can download the latest as well as any specific edition of the MongoDB Community database in Ubuntu 22.04.
Install the MongoDB Latest Version
Install the latest version of MongoDB by utilizing this command:
Output
The installation will take some time.
Wait for the completion of the latest edition of the MongoDB community in Ubuntu 22.04:
Install the Specific Version of MongoDB
However, to install any specific edition of the MongoDB community database. Execute the command provided below:
To download any specific edition, the user must list all required MongoDB product names and edition numbers.
Output
The output showed that the specified edition was installed successfully.
Step 5: Verify MongoDB Installation
To verify whether the MongoDB Community Edition 6.0.5 is installed successfully or not, run the given command:
Output
The output sent a ping request to the MongoDB server and displayed a response from it. In case of any error, start the MongoDB services.
Step 6: Manage MongoDB Service
Once the MongoDB Community Edition is installed, the user can start, stop, and enable the MongoDB services automatically.
To see the status of the MongoDB service, run this command:
Output
It returned the status of the MongoDB server as active.
Stop the MongoDB Service
Sometimes, the user needs to stop the MongoDB service to perform some configurations. To stop the service, run the command given below:
After stopping the service, execute the “status” command to see the MongoDB service.
Output
The MongoDB server stopped successfully.
Start the MongoDB Service
To start the MongoDB service, the user can run this command:
After starting the service, run the “status” command to see the MongoDB service:
Output
The MongoDB server started successfully.
Restart the MongoDB Service
Similarly, to restart the MongoDB server, run this command:
Output
The MongoDB server will restart successfully.
Step 7: Enable the MongoDB Service to Startup at Boot Automatically
The “enable” command can be utilized to start the MongoDB server automatically after every boot-up:
Output
This command starts the MongoDB server after every boot-up automatically.
Conclusion
To install the latest or specific edition of the MongoDB Community database, add the GPG key and repository of MongoDB in Ubuntu 22.04. After the installation, verify it by sending a ping request to the MongoDB server to see its response. The user can manage the services of MongoDB server. This post demonstrated the process of installing MongoDB Community Edition 6.0.5 on Ubuntu 22.04.