How To Duplicate Entire MySQL Database From Command Line

Download PDF

How To Duplicate Entire MySQL Database From Command Line is a frequently asked question as we often need to backup the database or restore the database quickly. In this short guide on How To Duplicate Entire MySQL Database From Command Line, we are giving example with Rackspace Cloud Server. It will definitely work with any other standard webhost.

 

How To Duplicate Entire MySQL Database From Command Line : What Can Be done ?

 

In this guide How To Duplicate Entire MySQL Database From Command Line, we will not only show the commands to backup or duplicate database of any web software or blogging software like WordPress, but also to pipe the output into another mysql command to import it into a different database or to and from localhost to server.

The major advantage is – there is no practical limit of import or export size of database, where as in PHPMyAdmin, there is a limit.

 

How To Duplicate Entire MySQL Database From Command Line

 

If you have used the classic way to Install WordPress on Rackspace Cloud Server or any server (there is also video guide for Installing WordPress on Rackspace Cloud Server in this way) or have ssh access with any control panel, then you can use these methods.

 

Simple way :

 

First, ssh to your server and login to MySQL. Create a database where you will duplicate it, take the name of the duplicate database is database2 :

 

 

Run this after changing with real values, databasename is the original database :

 

 

 

Import it into a different database (mysqldump and pipe the output)

 
How To Duplicate Entire MySQL Database From Command Line
 

Again, create a database. This is another method, do not run all these on the same database !

 

 

mysqldump command is used to create textfile “dumps” of databases managed by MySQL :

 

 

Actually this is the principle :

 

 

Restore :

 

 

Copy to localhost / local computer :

 

 

Copy to Server via SSH :

 

 

2 years back, we usually used to post these kind of small things. For a reason, those days came in mind. Just such a bundle of handy commands.
Abhishek-Ghosh

If you have enjoyed this article, please consider subscribing to our newsletter or share this post. As we have changed our whole website to HTTPS URL to protect your privacy, social counts will appear lower than they were on HTTP URL.

Here’s what we’ve got for you which might like :

Also, we have YouTube Videos and Apple iTunes Podcast Channel (the link will open iTunes App on Mac).

Additionally, performing a search on this website can help you.

Take The Conversation Further ...

We'd love to know your thoughts on this article.
Meet the Author over on Google+ or Twitter to join the conversation right now!

If you want to Advertise on our Article or want Business Partnership, you are invited to Contact us.

Contact Us