Wednesday, July 27, 2011

MySQL: Copy / clone database in MySQL

I needed to create a exact replica of my existing MySQL Magento database so that I could use it for my development.

A elegant solution was

mysqldump -u SRC_DB_USER --password=SRC_DB_PASSWORD -h SRC_DB_HOST SRC_DB_NAME | mysql -u DST_DB_USER --password=DST_DB_PASSWORD -h DST_DB_HOST DST_DB_NAME


where
- SRC_DB_* is the source database
- DST_DB+* is the destination Database

If you wanted to create a datavase also, you could have used

mysqladmin create  -u DST_DB_USER --password=DST_DB_PASSWORD -h DST_DB_HOST DST_DB_NAME && \
mysqldump -u SRC_DB_USER --password=SRC_DB_PASSWORD -h SRC_DB_HOST SRC_DB_NAME \
| mysql -u DST_DB_USER --password=DST_DB_PASSWORD -h DST_DB_HOST DST_DB_NAME




1 comment:

  1. casino, poker room, blackjack, bingo
    casino, https://vannienailor4166blog.blogspot.com/ poker room, blackjack, bingo room, blackjack, bingo room, poker room, poker bsjeon room, poker worrione room, poker room, poker room, https://septcasino.com/review/merit-casino/ poker room, herzamanindir.com/

    ReplyDelete