From 47d2b265b5c4b8e61964698ebbd68cb8f947f51d Mon Sep 17 00:00:00 2001 From: abenmiloud Date: Wed, 6 Oct 2021 17:30:18 +0200 Subject: [PATCH] =?UTF-8?q?Proc=C3=A9dure=20pour=20modifier=20mot=20de=20p?= =?UTF-8?q?asse=20`mongoAdmin`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HowtoMongoDB.md | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/HowtoMongoDB.md b/HowtoMongoDB.md index 18fdf846..24f070ac 100644 --- a/HowtoMongoDB.md +++ b/HowtoMongoDB.md @@ -743,3 +743,36 @@ env.MONGO_DB_URI mongodb://mongoMonitoring:PASSWORD@localhost:27017/admin ### NRPE : check_mongo TODO + +## FAQ + +### Modifier mot de passe `mongoAdmin` + +On va arrêter MongoDB et démarrer le service à la main en *background*. + +```bash +systemctl stop mongod.service +sudo -u mongodb /usr/bin/mongod --config /etc/mongod.conf --noauth & +mongo +``` + +Dans le *shell* MongoDB : + +```js +use admin; +db.createUser( { user: "mongoAdmin", pwd: "MOT_DE_PASSE", roles: [ { role: "userAdminAnyDatabase", db: "admin" } ] } ) +exit +``` + +Une fois sorti du *shell* MongoDB, on tue le service démarré à la main et on démarre MongoDB normalement : + +```bash +kill %% +systemctl start mongod.service +``` + +Pour vérifier si le mot de passe fonctionne : + +```bash +mongo -u mongoAdmin -p'MOT_DE_PASSE' +``` \ No newline at end of file