Install MongoDB on Debian 12
Install prerequisites
apt install curl apt-transport-https software-properties-common gnupg2 -y
Install public key
wget -qO - https://www.mongodb.org/static/pgp/server-6.0.asc | apt-key add -
Install repo
echo "deb https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/6.0 multiverse" > /etc/apt/sources.list.d/mongo-db-repo.list
Update packages
apt update
Install MongoDB
apt install mongodb-org
Start daemon
systemctl start mongod
Enable at boot time
systemctl enable mongod
Check version
mongod --version
db version v6.0.8
Build Info: {
"version": "6.0.8",
"gitVersion": "3d84c0dd4e5d99be0d69003652313e7eaf4cdd74",
"openSSLVersion": "OpenSSL 3.0.9 30 May 2023",
"modules": [],
"allocator": "tcmalloc",
"environment": {
"distmod": "ubuntu2204",
"distarch": "x86_64",
"target_arch": "x86_64"
}
}
Check status
service mongod status
● mongod.service - MongoDB Database Server
Loaded: loaded (/lib/systemd/system/mongod.service; enabled; preset: enabled)
Active: active (running) since Thu 2023-08-15 20:48:52 CEST; 3min 34s ago
Docs: https://docs.mongodb.org/manual
Main PID: 51372 (mongod)
Memory: 72.4M
CPU: 1.031s
CGroup: /system.slice/mongod.service
└─51372 /usr/bin/mongod --config /etc/mongod.conf
Aug 15 20:48:52 server systemd[1]: Started mongod.service - MongoDB Database Server.
Aug 15 20:48:52 server mongod[51372]: {"t":{"$date":"2023-08-15T18:48:52.791Z"},"s":"I", "c":"CONTROL", "id":7484500, "ctx":"-","msg":"Environment variable MONGODB_CONFIG_OVERRIDE_NOFORK == 1, overriding \"processManagement.fork\" to false"}
Check port
netstat -tulpen | grep mongod
tcp 0 0 localhost:27017 0.0.0.0:* LISTEN mongodb 189750 51372/mongod