Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Clone MySQL database

People also ask

What is clone in MySQL?

The clone plugin, introduced in MySQL 8.0. 17, permits cloning data locally or from a remote MySQL server instance. Cloned data is a physical snapshot of data stored in InnoDB that includes schemas, tables, tablespaces, and data dictionary metadata.

How do you make a copy of a database?

Expand Databases, right-click the desired database, point to Tasks, and then select Copy Database... If the Welcome to the Copy Database Wizard splash page appears, select Next. Select a Source Server page: Specify the server with the database to move or copy.


$ mysqldump yourFirstDatabase -u user -ppassword > yourDatabase.sql
$ mysql yourSecondDatabase -u user -ppassword < yourDatabase.sql

mysqldump -u <user> --password=<password> <DATABASE_NAME> | mysql -u <user> --password=<password> -h <hostname> <DATABASE_NAME_NEW>

Like accepted answer but without .sql files:

mysqldump sourcedb -u <USERNAME> -p<PASS> | mysql destdb -u <USERNAME> -p<PASS>

In case you use phpMyAdmin

  1. Select the database you wish to copy (by clicking on the database from the phpMyAdmin home screen).
  2. Once inside the database, select the Operations tab.
  3. Scroll down to the section where it says "Copy database to:"
  4. Type in the name of the new database.
  5. Select "structure and data" to copy everything. Alternately, you can select "Structure only" if you want the columns but not the data.
  6. Check the box "CREATE DATABASE before copying" to create a new database.
  7. Check the box "Add AUTO_INCREMENT value."
  8. Click on the Go button to proceed.

There is mysqldbcopy tool from the MySQL Utilities package. http://dev.mysql.com/doc/mysql-utilities/1.3/en/mysqldbcopy.html