Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

367
Vistas
Unable to copy a database from one mongodb account to another

I usually create a copy of a database in the same cluster in the same account like this:

  1. DUMP THE ORIGINAL DATABASE

mongodump --uri 'mongodb+srv://ACC_USER_NAME:ACC_USER_PASSWORD@cluster0.fklgt.mongodb.net/ORIGINAL_DATABASE_NAME' --archive="DUMP_FILE_NAME" --forceTableScan

  1. RESTORE THE DATABASE FROM THE DUMP FILE

mongorestore --uri 'mongodb+srv://ACC_USER_NAME:ACC_USER_PASSWORD@cluster0.fklgt.mongodb.net/ORIGINAL_DATABASE_NAME' --archive="DUMP_FILE_NAME" --nsFrom='ORIGINAL_DATABASE_NAME.' --nsTo='NEW_DATABASE_NAME.'

And that works perfectly.

Now, I created a new MongoDB atlas account, and I am trying to copy the original database into the new account.

So the first step is similar:

  1. DUMP THE ORIGINAL DATABASE

mongodump --uri 'mongodb+srv://ORIGINAL_ACC_USER_NAME:ORIGINAL_ACC_USER_PASSWORD@cluster0.fklgt.mongodb.net/ORIGINAL_DATABASE_NAME' --archive="DUMP_FILE_NAME" --forceTableScan

  1. RESTORE THE DATABASE FROM THE DUMP FILE

Here I could not find which params to use.
In the first example, in the second step, the URI is like this:

mongodb+srv://ACC_USER_NAME:ACC_USER_PASSWORD@cluster0.fklgt.mongodb.net/ORIGINAL_DATABASE_NAME

So I obviously should replace

ACC_USER_NAME:ACC_USER_PASSWORD

with

NEW_ACC_USER_NAME:NEW_ACC_USER_PASSWORD

But, what about the ORIGINAL_DATABASE_NAME, I could not find an equivalent to put there. The rest of the params:

--archive="DUMP_FILE_NAME" --nsFrom='ORIGINAL_DATABASE_NAME.' --nsTo='NEW_DATABASE_NAME.'

should remain the same.

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Step 1

First, you should do mongodump. You already did that correctly.

mongodump --uri mongodb+srv://<USER>:<PASSWORD>@cluster.xxx.mongodb.net/<DATABASE>

This command will create a BSON file, which we will use for restoring the database in the next step.

Step 2

Now, you can use mongorestore with new cluster connection string, and with BSON file from previous step.

mongorestore --uri mongodb+srv://<USER>:<PASSWORD>@new_cluster.xxx.mongodb.net <BSON_FILE_PATH>

NOTE: You don't need to specify ORIGINAL_DATABASE_NAME with mongorestore. You should only specify the base connection string of the new cluster. BSON file include all the necessary data for restoring the database. So, the database will be created in the new cluster and will have the same name as in the old cluster.

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda