MongoDb, Cloning database error: illegal argument combination: cannot specify --db and --uri
MongoDb, Cloning database error: illegal argument combination: cannot specify --db and --uri
我正在尝试在同一集群中复制名为 database_A
的数据库。
结果应该是一个名为 database_B
的新数据库,其中包含完全相同的数据。
我正在尝试按照说明进行操作 here。
它解释了如何在本地执行此操作:
- 使用 mongodump 将测试数据库转储到存档 mongodump-test-db:
mongodump --archive="mongodump-test-db" --db=test
- 使用带有 --nsFrom 和 --nsTo 的 mongorestore 从存档中恢复(更改数据库名称):
mongorestore --archive="mongodump-test-db" --nsFrom='test.'
--nsTo='examples.'
为了在集群中达到同样的效果,表示:
Include additional options as necessary, such as to specify the uri or
host, username, password and authentication database.
但是,当我尝试添加uri
来实现第一步时:
mongodump --uri mongodb+srv://hihi:password@cluster0.fklgt.mongodb.net --archive="mongodump-test-db" --db=test_db
我收到这个错误:
illegal argument combination: cannot specify --db and --uri
知道如何解决这个问题吗?
您必须在类似 URI 的连接中添加数据库 uri/[db]
mongodb+srv://hihi:password@cluster0.fklgt.mongodb.net/test_db
mongodump --uri mongodb+srv://hihi:password@cluster0.fklgt.mongodb.net/test_db --archive="mongodump-test-db"
https://docs.mongodb.com/v3.6/reference/program/mongodump/#cmdoption-mongodump-uri
/database Optional. The name of the database to authenticate if the connection string includes authentication credentials in the form of username:password@. If /database is not specified and the connection string includes credentials, the driver will authenticate to the admin database. See also authSource.
我正在尝试在同一集群中复制名为 database_A
的数据库。
结果应该是一个名为 database_B
的新数据库,其中包含完全相同的数据。
我正在尝试按照说明进行操作 here。
它解释了如何在本地执行此操作:
- 使用 mongodump 将测试数据库转储到存档 mongodump-test-db:
mongodump --archive="mongodump-test-db" --db=test
- 使用带有 --nsFrom 和 --nsTo 的 mongorestore 从存档中恢复(更改数据库名称):
mongorestore --archive="mongodump-test-db" --nsFrom='test.' --nsTo='examples.'
为了在集群中达到同样的效果,表示:
Include additional options as necessary, such as to specify the uri or host, username, password and authentication database.
但是,当我尝试添加uri
来实现第一步时:
mongodump --uri mongodb+srv://hihi:password@cluster0.fklgt.mongodb.net --archive="mongodump-test-db" --db=test_db
我收到这个错误:
illegal argument combination: cannot specify --db and --uri
知道如何解决这个问题吗?
您必须在类似 URI 的连接中添加数据库 uri/[db]
mongodb+srv://hihi:password@cluster0.fklgt.mongodb.net/test_db
mongodump --uri mongodb+srv://hihi:password@cluster0.fklgt.mongodb.net/test_db --archive="mongodump-test-db"
https://docs.mongodb.com/v3.6/reference/program/mongodump/#cmdoption-mongodump-uri
/database Optional. The name of the database to authenticate if the connection string includes authentication credentials in the form of username:password@. If /database is not specified and the connection string includes credentials, the driver will authenticate to the admin database. See also authSource.