views:

97

answers:

2

I am currently looking for a quick way to sync my production db and my dev-db.

I was thinking of doing it with something like this :

mysqladmin -u <user> -p<password> <dev-db_name> | mysqldump -u <user> -p<password> --databases <production-db-name> --add-drop-table

but it seems that it just prints all of the drump on the screen instead of piping it to the mysqladmin util. Would there be any suggestion to improve this ?

+5  A: 

Right now you are piping the output of mysqladmin into mysqldump.

Flip them around, also instead of mysqladmin use regular mysql, to that the command like looks something like this:

mysqldump ... | mysql ...
andri
I just tried and got this error on the first table mysqldump: Error 2013: Lost connection to MySQL server during query when dumping table `acces` at row: 1388 any idea ?
Erick
Hm. Try dumping into a file first, that is, without piping it straight to mysql client, do something like "mysqldump ... > script.sql" and see if that succeeds.
andri
Seems to be the way to go. Thanks for the tip :-)
Erick
A: 

You could also look into the master / slave replication paradigm... if you just need to read from the dev-db, this is perfect...

Varkhan
Yup but problem is 1- it's relatively complicated2- cpanel3- I need to only sync sometimes, not each night (in case I test db manipulations and I want to keep it the next day). But otherwise, great idea :)
Erick