Table of Contents
- Overview
- Considerations
- Import the Public Key
- Create a List File for MongoDB
- Reload Local Package Database
- Install MongoDB Packages
- Run MongoDB Community Edition
- Uninstall MongoDB Community Edition
- Additional Information
Overview
This guide will walk you through the process of installing MongoDB 7.0 Community Edition on Ubuntu Linux using the `apt` package manager. MongoDB is a popular NoSQL database that offers high performance, high availability, and easy scalability.
Considerations
Before proceeding with the installation, please note the following:
- MongoDB 7.0 Community Edition supports 64-bit Ubuntu LTS releases on x86_64 architecture:
- 22.04 LTS ("Jammy")
- 20.04 LTS ("Focal")
- ARM64 architecture is supported on select platforms.
- The official `mongodb-org` package will be used for installation, which is maintained and supported by MongoDB Inc.
1. Import the Public Key
First, install `gnupg` and `curl` if they're not already available:
sudo apt-get install gnupg curl
Then, import the MongoDB public GPG key:
curl -fsSL https://www.mongodb.org/static/pgp/server-7.0.asc | \
sudo gpg -o /usr/share/keyrings/mongodb-server-7.0.gpg \
--dearmor
2. Create a List File for MongoDB
Create the list file `/etc/apt/sources.list.d/mongodb-org-7.0.list` for your version of Ubuntu:
For Ubuntu 22.04 (Jammy):echo "deb [ arch=amd64,arm64 signed-by=/usr/share/keyrings/mongodb-server-7.0.gpg ] https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/7.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-7.0.list
For Ubuntu 20.04 (Focal):
echo "deb [ arch=amd64,arm64 signed-by=/usr/share/keyrings/mongodb-server-7.0.gpg ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/7.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-7.0.list
3. Reload Local Package Database
Update the local package database:
sudo apt-get update
4. Install MongoDB Packages
To install the latest stable version of MongoDB:
sudo apt-get install -y mongodb-org
To install a specific version (e.g., 7.0.14):
sudo apt-get install -y mongodb-org=7.0.14 mongodb-org-database=7.0.14 mongodb-org-server=7.0.14 mongodb-mongosh=7.0.14 mongodb-org-mongos=7.0.14 mongodb-org-tools=7.0.14
5. Run MongoDB Community Edition
Start the MongoDB service:
sudo systemctl start mongod
Verify that MongoDB has started successfully:
sudo systemctl status mongod
To enable MongoDB to start on system reboot:
sudo systemctl enable mongod
To begin using MongoDB, start a `mongosh` session:
mongosh
6. Uninstall MongoDB Community Edition
To completely remove MongoDB:
1. Stop the MongoDB service:sudo service mongod stop
2. Remove the packages:
sudo apt-get purge "mongodb-org*"
3. Remove data directories:
sudo rm -r /var/log/mongodb
sudo rm -r /var/lib/mongodb
7. Additional Information
By default, MongoDB binds to localhost (127.0.0.1). To allow remote connections, you need to modify the `bindIp` setting in the MongoDB configuration file (`/etc/mongod.conf`) or use the `--bind_ip` command-line option.
For more detailed information and advanced configuration options, please refer to the [official MongoDB documentation](https://www.mongodb.com/docs/manual/tutorial/install-mongodb-on-ubuntu/).
Facing issues? Have Questions? Post them here! I am happy to answer!
- Block Select Text in TextEdit on Mac - MacOS
- [Fix] Steam Friends Network Unreachable Error - HowTos
- How to start or open a new bourne-again shell (bash) session on Windows using Command Line CMD - Bash
- Display Safari URL address link on hover - MacOS
- [Working] Steps to Install Windows 10/11 on M1/M2 Mac using a Free VM - MacOS
- Mac Terminal Find Command History - MacOS
- Java Interview Question: Can a Constructor in Java have a Return type? - Java
- Add Syntax Highlighting in Zsh Shell - zsh