본문 바로가기

IT/Database

[mongodb] db 복제

1.복제 해 와서 붙여넣을 mongodb에 접속한다.


2. 다음 명령을 실행한다.

db.copyDatabase(fromdb, todb, fromhost, username, password)

Copies a database from a remote host to the current host or copies a database to another database within the current host. db.copyDatabase() wraps the copydb command and takes the following arguments:



Parameter Type Description
fromdb string The name of the source database.
todb string The name of the destination database.
fromhost string Optional. The name of the source database host. Omit the hostname to copy from one database to another on the same server.
username string Optional. The username credentials on the fromhost for authentication and authorization.
password string Optional. The password on the fromhost for authentication and authorization. The method does not transmit the password in plaintext.


*** 주의 : 옵션들은 쌍따옴표(")로 각각 감싸주어야 한다. (그렇지 않으면 Unexpected Token을 뱉어낸다....)


출처 : 껸, mongodb.org