Installing `mongorestore` on Ubuntu 22.04
When working with MongoDB, the mongorestore utility is an essential tool for restoring databases from BSON dump files. On Ubuntu 22.04, mongorestore is included in the MongoDB Database Tools package, which is distributed separately from the MongoDB server. This guide walks you through the installation process step by step. Step 1: Import the MongoDB Public GPG Key Before adding the MongoDB repository, you need to import its public GPG key:
|
1 2 |
curl -fsSL https://pgp.mongodb.com/server-6.0.asc | sudo gpg --dearmor -o /usr/share/keyrings/mongodb-server-6.0.gpg |
Step 2: Add the MongoDB APT Repository Add the MongoDB repository to your system’s APT sources:
|
1 2 |
echo "deb [ arch=amd64,arm64 signed-by=/usr/share/keyrings/mongodb-server-6.0.gpg ] https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/6.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-6.0.list |
Step 3: Update the Package List Update the local package index to include the new MongoDB repository:
|
1 2 |
sudo apt-get update |
Step 4: Install the MongoDB Database Tools Install the tools package, which includes mongorestore along with other utilities such as mongodump, mongoimport, and mongoexport:
|
1 2 |
sudo apt-get install -y mongodb-database-tools |
Step 5: Verify the Installation Confirm that mongorestore is installed and available on your system:
|
1 2 |
mongorestore --version |
You should see