ubuntu24.04 install mongodb (亲测可用)

1Update the system and install dependencies. First, update the package list and install curl and gnupg

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

2.添加MongoDB GPG密钥  Add the MongoDB repository to your APT repository sources.

$ curl -fsSL https://www.mongodb.org/static/pgp/server-8.0.asc | sudo gpg -o /usr/share/keyrings/mongodb-server-8.0.gpg --dearmor

3.Add the MongoDB repository to your APT repository sources.

$ echo "deb [ arch=amd64,arm64 signed-by=/usr/share/keyrings/mongodb-server-8.0.gpg ] https://repo.mongodb.org/apt/ubuntu noble/mongodb-org/8.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-8.0.list

4.Update the APT package index to apply the MongoDB repository changes.

$ sudo apt update

5.Install MongoDB.

$ sudo apt install -y mongodb-org

6.Verify the installed MongoDB version.

$ mongod --version
Your output should be similar to the one below.

image

Manage the MongoDB System Service

1.Enable MongoDB to start automatically at boot.

$ sudo systemctl enable mongod

2.Start the MongoDB service.

$ sudo systemctl start mongod

3.View the MongoDB service status to verify that it’s running.

$ sudo systemctl status mongod



 

 


posted @ 2025-12-10 17:30  adao  阅读(2)  评论(0)    收藏  举报