Archive

Posts Tagged ‘copy database’

Copy Complete MySQL database

February 22nd, 2013 No comments

Here are simple ways you can make a copy of a base in MySQL. It is essential that you have access to the command line.

        

  • create a database in which you want to transfer data via phpMyAdmin or a similar tool
        

  • From the console, execute the following command:

    mysqldump -h [server] -u [user] -p[password] db1 | mysql -h [server] -u [user] -p[password] db2
    

    Note that between -p and [password] no spaces.

    If the command is running in the system that is not password protected (typically servers on the local computer) parameter with a password can be omitted. These commands can be executed in two steps as follows:

    mysqldump -h [server] -u [user] -p[password] db1 > dump.sql
    mysql -h [server] -u [user] -p[password] db2 < dump.sql
    

    In this way he created mysqldump file that can be saved as a backup.

Categories: MySQL Tags: , ,