De Wiki inetshell
Saltar a: navegación, buscar

Operaciones Basicas

# Listar databases
show dbs

# Usar database
use databasename

# Listar collections
show collections

# Listar collections (Formas alternas)
show tables
db.getCollectionNames()

Respaldo y restauracion

https://stackoverflow.com/questions/11255630/how-to-export-all-collections-in-mongodb

# Respaldo
mongodump -d <database_name> -o <directory_backup>

# Restauracion
mongorestore -d <database_name> <directory_backup>

# Restauracion con autenticacion
mongorestore --authenticationDatabase=admin -u <user> -d <database_name> <directory_backup>