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.xmlof the cloned installation. - Clear the cache by emptying
var/cache(andvar/full_page_cacheif used). - Adjust the Base URLs in
core_config_dataso the clone runs under its own domain.
Post Comments
Be the first to share your thoughts on this post.
Submit Comment