← Tous les guides
MongoDB Community Edition
A free, open-source, document-oriented NoSQL database -- installed from MongoDB's own official APT repository (not Ubuntu's default one, which typically lags behind).
Ce guide est élaboré à partir de la documentation officielle de MongoDB Community Edition, dont le lien figure ci-dessus — vérifiez toujours les noms exacts des paquets/versions avant d'exécuter ces commandes sur un serveur de production, car les versions de la distribution et du projet évoluent avec le temps.
1Import MongoDB's official GPG key and repository
curl -fsSL https://pgp.mongodb.com/server-7.0.asc | sudo gpg --dearmor -o /usr/share/keyrings/mongodb-server-7.0.gpgecho "deb [signed-by=/usr/share/keyrings/mongodb-server-7.0.gpg] https://repo.mongodb.org/apt/ubuntu $(lsb_release -cs)/mongodb-org/7.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-7.0.listCheck MongoDB's own install docs (linked above) for the current recommended version number -- this changes as new major versions are released.
2Install it
sudo apt updatesudo apt install mongodb-org3Start and enable the service
sudo systemctl start mongodsudo systemctl enable mongod4Create an admin user
mongoshuse admindb.createUser({ user: "admin", pwd: "a-real-password", roles: ["root"] })MongoDB has no authentication enabled by default -- create this user, then enable `security.authorization: enabled` in /etc/mongod.conf and restart, or anyone who can reach the port has full access.