« Mongodb » : différence entre les versions
De Banane Atomic
Aller à la navigationAller à la recherche
Aucun résumé des modifications |
|||
Ligne 10 : | Ligne 10 : | ||
</kode> | </kode> | ||
== | == Authenticate == | ||
<kode lang='mongo'> | <kode lang='mongo'> | ||
use admin | use admin | ||
Ligne 17 : | Ligne 17 : | ||
db.auth("username", passwordPrompt()) | db.auth("username", passwordPrompt()) | ||
</kode> | |||
= Backup and restore = | |||
<kode lang='bash'> | |||
# restore the backup folder dump to the local mongodb instance | |||
mongorestore dump/ | |||
</kode> | |||
== don't know what to do with file while restore == | |||
This may happen because the {{boxx|mongorestore}} command point to a backup sub-folder not to the backup folder itself. | |||
= [https://www.mongodb.com/features/mongodb-authentication Authentication] = | |||
<kode lang='mongo'> | |||
# create user | # create user | ||
use admin | use admin | ||
Ligne 29 : | Ligne 41 : | ||
</kode> | </kode> | ||
<filebox fn='/etc/mongod.conf'> | |||
< | security: | ||
authorization: "enabled" | |||
</filebox> | |||
</ | |||
= Compass = | = Compass = |
Version du 8 mars 2023 à 12:46
Connect and authenticate
# 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()) |
Backup and restore
# restore the backup folder dump to the local mongodb instance mongorestore dump/ |
don't know what to do with file while restore
This may happen because the mongorestore command point to a backup sub-folder not to the backup folder itself.
Authentication
Fichier:Mongo.svg | # create user use admin db.createUser( { user: "myuser", pwd: "mypwd", roles: [ { role: "userAdminAnyDatabase", db: "admin" } ] } ) |
/etc/mongod.conf |
security: authorization: "enabled" |
Compass
Installation
Windows
choco install mongodb mongodb-shell |
Key | Value |
---|---|
Service name | MongoDB |
Data directory | C:\Program Files\MongoDB\Server\6.0\data\ |
Log directory | C:\Program Files\MongoDB\Server\6.0\log\ |
- Install the Database Tools in C:\Program Files\MongoDB\Tools