Tell me more ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Is there a way to sync a MySQL database with a remote one either automatically or with a script? The data is not time sensitive, but I don't want to have to export it out of the local database and then import it into the remote one.

I am one Windows Vista and using XAMPP as my local stack.

share|improve this question

2 Answers

Replication works quite good, and it's not hard to configure. The official doc (for 5.1) it's easy to follow.

share|improve this answer

If the database you are syncing from is a Windows machine and the remote machine with MySQL is in Linux, you could pipe the mysqldump straight through to the remote mysql database:

mysqldump -hlocalhost -uusername -ppassword --single-transaction --flush-privileges --routines --triggers --all-databases | mysql -A -hremoteIpAddress -uremoteusername -premotepassword

CAVEAT

You need to be careful doing this from local to remote

  • The network could timeout if running a very long reindex phase (aka ALTER TABLE tblname ENABLE KEYS) of a MyISAM table. The dump will terminate prematurely. (Dumping to local text file alleviates this worry, which are currently doing)
  • Make sure table names and database names do not present case sensitivity problems. This could rear its ugly head if importing InnoDB tables with foreign key constraints. To be safe, make sure every table is lowercase in the Windows machine (Check out lower_case_table_names, perhaps setting it to 1 on the Window installation of mysql)
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.