How to Install MongoDB Community Edition 6.0.5 on Debian 11?
MongoDB community’s latest edition is 6.0.5 which can be utilized to store data in the form of documents. The user can install it easily in Debian 11 by following the mentioned steps:
Step 1: Import MongoDB Public GPG Key
To import the GPG key, Debian must have the GnuPG package installed. If it is not available in any case execute this command:
Output
To import the public GPG key of MongoDB from its official website, utilize the wget command:
sudo gpg -o /usr/share/keyrings/mongodb-server-6.0.gpg \
--dearmor
Output
The MongoDB key has been added successfully in Debian 11.
Step 2: Add MongoDB Repository in Debian 11
Run this command to add the MongoDB repository in Debian 11:
Output
The output returned a message after adding the MongoDB repository.
Step 3: Reload the Package Information
After adding the GPG key and repository, it is necessary to update the package information using this command:
Output
The update of package information has been completed.
Step 4: Install the MongoDB Community Edition 6.0.5
As MongoDB Community Edition 6.0.5 is the latest, users can install the latest edition by executing the command provided below:
Output
Wait for the installation to complete.
However, if the new releases come and the user still wants to install any specific version, such as “5.0.8”, “6.0.4” or “6.0.5”. They need to mention the MongoDB products with the version number individually as shown below:
Output
The output shows that MongoDB Community Edition 6.0.5 is installed.
Step 5: Verify Installation of MongoDB Community Edition 6.0.5
To verify the installation, execute this command to see the version details of the install MongoDB:
Output
The output indicated the details of the installed MongoDB version.
Step 6: Start the MongoDB Service
After the verification, start the MongoDB server service by executing the provided command:
Check the status of the MongoDB server service by running the command given below:
Output
The output showed an error which mostly occurs in Debian 11.
Let us see the procedure to solve this issue in Debian 11.
Resolve this Error
To resolve this error, delete the “/tmp/mongodb-27017.sock ” file using the given command:
Reload the MongoDB server services by running this command:
After reloading the server service, start it by executing the command mentioned below:
Output
The output displays that the error is resolved, and the MongoDB server started successfully.
Step 7: Manage the MongoDB Services
The user can stop these server services by running this command:
After executing the above command run the status command to verify the working of the command.
Output
The output returned the “inactive” status.
To restart these services, utilize the given below command:
Lastly, run the status command again to see the changes made by the above command:
Output
The output shows that services have been restarted.
Conclusion
To install the latest or specific edition (6.0.5) of the MongoDB Community, import the MongoDB GPG key and add the repository from its official website in Debian 11. After that, check the version details of the installed MongoDB server. In Debian 11, an error occurs after installation on starting the server usually. Follow the steps in the blog to resolve that error. However, users can start, stop, and restart the MongoDB server service.