Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

363
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda