...
This user afterwards is used by the BVQ services & UIs to connect to the database. Whenever you change the password of the user remeber to change it in the other BVQ modules (GUI DB connection profile, etc.)
Table of Contents |
---|
Connect to MongoDB with mongo CLI
Establish a connection to MongoDB via mongo CLI (use CMD or PowerShell) (see https://docs.mongodb.com/v3.4/reference/program/mongo/)
No Format mongo --authenticationDatabase admin -u bvq -p Passwort
(default location of binaries = C:\Program Files\SVA\BVQ\bvq-mongodb\bin, put in PATH variable to access from outside the directory
change username -u and password -p to your credentials)
Change the password of an existing user
- Establish a connection to MongoDB via mongo CLI (see Connect to MongoDB with mongo CLI)
The user information is configured globally for the entire MongoDB within the
admin
DB, so you have to switch to this DB.
List existing dbs withshow dbs
commandNo Format PS C:\Users\XXX> mongo --authenticationDatabase admin -u bvq -p Passwort MongoDB shell version v3.4.4 connecting to: mongodb://127.0.0.1:27017 MongoDB server version: 3.4.4 > show dbs admin 0.000GB bvq 0.401GB local 0.000GB
Switch to admin db with
use admin
No Format > use admin switched to db admin
Use
db.changeUserPassword()
to change the password for the user logged in (see https://docs.mongodb.com/v3.4/reference/method/db.changeUserPassword/)
In this example password is changed toNo Format db.changeUserPassword("bvq", "NEW_PASSWORD")
NEW_PASSWORD
for userbvq
After executing this command the password will be changed
PS C:\Users\XXX> mongo --authenticationDatabase admin -u bvq -p Passwort MongoDB shell version v3.4.4 connecting to: mongodb://127.0.0.1:27017 MongoDB server version: 3.4.4 2017-12-05T18:50:07.771+0100 E QUERY [thread1] Error: Authentication failed. : DB.prototype._authOrThrow@src/mongo/shell/db.js:1459:20 @(auth):6:1 @(auth):1:2 exception: login failed PS C:\Users\fschenke> mongo --authenticationDatabase admin -u bvq -p NEW_PASSWORD MongoDB shell version v3.4.4 connecting to: mongodb://127.0.0.1:27017 MongoDB server version: 3.4.4 > exit bye PS C:\Users\XXX>No Format
List existing users
- Establish a connection to MongoDB via mongo CLI (see Connect to MongoDB with mongo CLI)
Switch to admin db with
use admin
No Format > use admin switched to db admin
Use
db.getUsers()
to list existing users (see https://docs.mongodb.com/v3.4/reference/method/db.getUsers/)No Format > db.getUsers() [ { "_id" : "admin.bvq", "user" : "bvq", "db" : "admin", "roles" : [ { "role" : "root", "db" : "admin" } ] } ]
...