Duplicate a MySQL database

I was testing something out, and realized that I needed to clone my database to run some tests while still being able to keep the data intact. And that’s when I started searching for a way to do it, and turns out there’s a one-liner to do the same ๐Ÿ™‚

# mysqladmin create DB_name -u DB_user --password=DB_pass && \
mysqldump -u DB_user --password=DB_pass DB_name |
mysql -u DB_userย --password=DB_pass -h DB_host DB_name

This is the site where I found it: http://www.rubyrobot.org/article/duplicate-a-mysql-databaseย (although at this point of time I’m kinda feeling it was moot writing this post as anyone Googling for the solution can land on the page anyway ๐Ÿ˜› )

Gotta run! Peace out.


One thought on “Duplicate a MySQL database

  1. well because you mentioned the link if will now be higher up in the results and so people would benefit. Peace out! ๐Ÿ˜›

    PS: assuming you are a big name by now ๐Ÿ˜€

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s