
{{ $('Map tags to IDs').item.json.title }}
How to Install MongoDB
MongoDB is a widely-used NoSQL database that stores data in flexible, JSON-like documents. It is known for being highly scalable and easy to use. This tutorial will guide you through the installation of MongoDB on your Linux system.
1. Importing the Public Key
First, import the public GPG key used by the package management system. Open your terminal and run:
wget -qO - https://www.mongodb.org/static/pgp/server-4.4.asc | sudo apt-key add -
This command fetches the MongoDB public GPG key and adds it to your system.
2. Creating the List File
Next, create a list file for MongoDB. For Ubuntu, run:
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/multiverse amd64 packaging /" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.4.list
3. Updating Package List
After adding the MongoDB repository, update your package index:
sudo apt update
4. Installing MongoDB
Now you can install MongoDB with the following command:
sudo apt install -y mongodb-org
This command will install the latest stable version of MongoDB along with its associated tools.
5. Starting MongoDB
To start the MongoDB service, run:
sudo systemctl start mongod
To ensure that MongoDB starts automatically on boot:
sudo systemctl enable mongod
6. Verifying the Installation
You can verify that MongoDB has started correctly and is running with:
sudo systemctl status mongod
You should see an output indicating that mongod
is active (running).
7. Accessing the MongoDB Shell
To interact with your MongoDB database, you can use the MongoDB shell:
mongo
This command enters the MongoDB shell prompt, where you can start executing MongoDB commands.
8. Conclusion
By following this tutorial, you have successfully installed MongoDB on your Linux system. MongoDB is a powerful NoSQL database that allows for flexible data management and scalability. Continue to explore its features and commands to effectively manage your databases!