Introduction:
MongoDB is a popular open-source NoSQL database system known for its flexibility and scalability. If you’re using Ubuntu 22.04 and want to install MongoDB, this step-by-step guide will walk you through the installation process.
Step 1: Import MongoDB GPG Key
- Open a terminal on your Ubuntu 22.04 system.
- Import the MongoDB GPG key by running the following command:
wget -qO - https://www.mongodb.org/static/pgp/server-5.0.asc | sudo apt-key add -
Step 2: Add MongoDB Repository
- Add the MongoDB repository to the APT sources list by executing the following command:
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/5.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-5.0.list
2. Update the system packages to include the new MongoDB repository:
sudo apt update
Step 3: Install MongoDB
- Install the MongoDB package by running the following command:
sudo apt install mongodb-org
2. Enter ‘Y’ when prompted to confirm the installation.
3. Wait for the installation to complete.
Step 4: Start and Enable MongoDB
- Start the MongoDB service by running the following command:
sudo systemctl start mongod
2. Enable the MongoDB service to start automatically on system boot:
sudo systemctl enable mongod
Step 5: Verify MongoDB Installation
- Check the status of the MongoDB service by executing the following command:
sudo systemctl status mongod
If the service is active and running, it means MongoDB has been successfully installed.
2. You can also verify the installation by accessing the MongoDB shell:
mongo
If the MongoDB shell opens without any errors, it confirms a successful installation.
Conclusion:
By following the steps outlined in this article, you can easily install MongoDB on your Ubuntu 22.04 system. MongoDB provides a powerful and flexible NoSQL database solution, allowing you to store and manage data efficiently. Take advantage of its scalability, high performance, and rich querying capabilities for your application needs. Install MongoDB and leverage its features to build robust and scalable database-driven applications on your Ubuntu 22.04 environment.