tags:

views:

73

answers:

3

Anyone know of a PHP script that will clone an entire MySQL database to another on another server? As a sort of backup?

+5  A: 

phpMyAdmin does this very well. Of course, if you had shell access, try this instead:

mysqldump -u [username] -p [password] [database] > [filename]
Delan Azabani
I am not quite sure what to do with that.
TechplexEngineer
+1 definitely use `mysqldump` to backup/clone your database.
Daniel Vandersluis
+1  A: 

You'd have your PHP script run (with e.g. the exec() or system() call) something like

mysqldump -q -C --databases mydatabase | mysql -C -h othermachine

Add the appropriate flags to these commands for specifying credentials, etc.

nos
A: 

You can refer this link. -

http://dev.mysql.com/doc/refman/5.1/en/mysqldump.html

This page is titled

MYSQL DUMP — A Database Backup Program

It contains all the details.

Hope this helps you.

Alpesh