3

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

2
  • 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? Commented Sep 19, 2010 at 1:42
  • 1
    You could adjust this: electrictoolbox.com/php-script-backup-copy-mysql-table Commented Sep 19, 2010 at 1:42

3 Answers 3

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.

Sign up to request clarification or add additional context in comments.

Comments

6

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

mysqldump -u [username] -p [password] [database] > [filename]

2 Comments

I am not quite sure what to do with that.
It created file.But there are no any data. 0 bytes. Can you help me.
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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.