Herzlich willkommen

How to Clone a Magento MySQL Database

Cloning a Magento database is the safest way to set up a staging or test environment without touching your live data. On the server command line you create a dump of the existing database and import it into a new one.

1. Export the existing database

mysqldump -u USERNAME -p EXISTING_DBNAME > dump.sql

For large shops, a transaction-consistent, compressed dump is faster and avoids locking:

mysqldump -u USERNAME -p --single-transaction --quick EXISTING_DBNAME | gzip > dump.sql.gz

2. Create the new (empty) database

mysql -u USERNAME -p -e "CREATE DATABASE NEW_DBNAME DEFAULT CHARSET utf8;"

3. Import the dump into the new database

mysql -u USERNAME -p NEW_DBNAME < dump.sql

For a gzipped dump:

gunzip < dump.sql.gz | mysql -u USERNAME -p NEW_DBNAME

4. Point Magento at the clone

  • Update the database name in app/etc/local.xml of the cloned installation.
  • Clear the cache by emptying var/cache (and var/full_page_cache if used).
  • Adjust the Base URLs in core_config_data so the clone runs under its own domain.

Post Comments

Be the first to share your thoughts on this post.

Submit Comment

This is a question to proof that you are a human.

* Required Fields