Anyone know of a PHP script that will clone an entire MySQL database to another on another server? As a sort of backup?
Asked
Active
Viewed 7,093 times
3
-
I guess what I'm really looking for is something that will automatically detect teh number of tables, rows in each table, and then loop through them all, and do the appropriate create operation on a remote database.(Automatically) If so where do I get it, or ahow do I make phpMyAdmin do it? – TechplexEngineer Sep 19 '10 at 01:42
-
1You could adjust this: http://www.electrictoolbox.com/php-script-backup-copy-mysql-table/ – miku Sep 19 '10 at 01:42
3 Answers
6
phpMyAdmin does this very well. Of course, if you had shell access, try this instead:
mysqldump -u [username] -p [password] [database] > [filename]

Delan Azabani
- 79,602
- 28
- 170
- 210
-
-
It created file.But there are no any data. 0 bytes. Can you help me. – Sumith Harshan Jan 12 '13 at 13:58
6
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
- 223,662
- 58
- 417
- 506
1
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
- 5,307
- 2
- 19
- 19