我们能为您提供什么帮助?

搜索我们的指南和教程,或浏览下方分类。

How to Install MongoDB on Ubuntu VPS

193 次浏览 Markdown

1.Install Required Tools (gnupg & curl)

sudo apt-get update
sudo apt-get install -y gnupg curl

These are needed to import MongoDB’s GPG key.

2. Import the MongoDB GPG Key

curl -fsSL https://pgp.mongodb.com/server-8.0.asc \
| sudo gpg -o /usr/share/keyrings/mongodb-server-8.0.gpg --dearmor

3. Add the MongoDB APT Repository

Create the repo file:

echo "deb [ signed-by=/usr/share/keyrings/mongodb-server-8.0.gpg ] \
https://repo.mongodb.org/apt/ubuntu $(lsb_release -sc)/mongodb-org/8.0 multiverse" \
| sudo tee /etc/apt/sources.list.d/mongodb-org-8.0.list

This tells Ubuntu where to fetch official MongoDB packages.

4. Update Package Index

sudo apt-get update

5. Install MongoDB

sudo apt-get install -y mongodb-org

6. Start & Enable MongoDB Service

Start MongoDB:

sudo systemctl start mongod

Enable on boot:

sudo systemctl enable mongod

Check status:

sudo systemctl status mongod

7. Verify MongoDB is Running

mongosh

这对您有帮助吗?

感谢您的反馈!

仍需帮助?

如果上述内容未能解答您的问题,我们的支持团队全天候为您服务。