Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Duplicate Entire MySQL Database

Is it posible to duplicate an entire MySQL database on a linux server?

I know I can use export and import but the original database is >25MB so that's not ideal.

Is it possible using mysqldump or by directly duplicates the database files?

like image 255
Adam Dempsey Avatar asked Dec 11 '09 13:12

Adam Dempsey


2 Answers

First create the duplicate database:

CREATE DATABASE duplicateddb; 

Make sure the user and permissions are all in place and:

 mysqldump -u admin -p originaldb | mysql -u backup -pPassword duplicateddb;  
like image 108
Vincent Ramdhanie Avatar answered Sep 18 '22 05:09

Vincent Ramdhanie


To remote server

mysqldump mydbname | ssh host2 "mysql mydbcopy" 

To local server

mysqldump mydbname | mysql mydbcopy 
like image 36
Peter Lindqvist Avatar answered Sep 20 '22 05:09

Peter Lindqvist