« Mongodb » : différence entre les versions

De Banane Atomic
Aller à la navigationAller à la recherche
(Page créée avec « = Connect = <filebox fn='bash'> mongo mongodb://localhost:27017 # alias mongo </filebox> »)
 
Aucun résumé des modifications
Ligne 1 : Ligne 1 :
= Connect =
= Connect and authenticate =
<filebox fn='bash'>
<kode lang='bash'>
# connect
mongo mongodb://localhost:27017
mongo mongodb://localhost:27017
# alias
# alias
mongo
mongo
</filebox>
 
# connect and authenticate, use an environment variable to hide the password
mongo "mongodb://user:${DBPASSWORD}@<host>:<port>/admin?authSource=admin"
</kode>
 
== Authenticate ==
<kode lang='mongo'>
db.auth("username", "pwd")
 
db.auth("username", passwordPrompt())
</kode>

Version du 6 mars 2023 à 15:57

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
db.auth("username", "pwd")

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