How to copy a mysql database

0

While there is no “copy database” function for mysql, there is a way to automate the process better than saving a bunch of SQL to a file, then uploading the file. Mysqldump offers a way to copy a database to another existing database on the same server or a remote server. The official documentation is here http://dev.mysql.com/doc/refman/5.0/en/mysqldump.html , although their syntax doesn’t include the required username and password login syntax (if your database server requires a login, I hope).

Use the following on linux –
mysqldump nameofdatabase1 -u root -p | mysql –host=localhost -u root -p -C nameofdatabase2;

You’ll be prompted for the password and you’ll need to enter it twice. If your destination database is remote, then replace localhost with the IP address.

Posted in: MySQL
Tags:

Leave a Reply

Your email address will not be published. Required fields are marked *

*




You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">