« Mongodb » : différence entre les versions

De Banane Atomic
Aller à la navigationAller à la recherche
Aucun résumé des modifications
Ligne 12 : Ligne 12 :
== Authenticate ==
== Authenticate ==
<kode lang='mongo'>
<kode lang='mongo'>
use admin
db.auth("username", "pwd")
db.auth("username", "pwd")


db.auth("username", passwordPrompt())
db.auth("username", passwordPrompt())
</kode>
</kode>

Version du 6 mars 2023 à 16:00

Connect and authenticate

Bash.svg
# connect
mongo mongodb://localhost:27017
# alias
mongo

# connect and authenticate, use an environment variable to hide the password
mongo "mongodb://user:${DBPASSWORD}@<host>:<port>/admin?authSource=admin"

Authenticate

Fichier:Mongo.svg
use admin

db.auth("username", "pwd")

db.auth("username", passwordPrompt())