My (SQL) WorkLog: MySQL - Copying records from remote server DB table to local server DB table

Wednesday, June 17, 2009

MySQL - Copying records from remote server DB table to local server DB table

Sometime you may need to populate(sync) local testing table with the production table which is hosted on a remote server.


# This command should be run on local server(SINGLE COMMAND)


mysqldump -t -h [remote_host_ip] -u[remote_User] -p[remote_Password] [remote_DbName] [remote_TableName] | mysql -h localhost -u [local_User] -p[local_Password] [local_DbName]



What if you want to copy last month data only?

mysqldump -t -h [remote_host_ip] -u[remote_User] -p[remote_Password] [remote_DbName] [remote_TableName] -w "column_date_time > NOW() - INTERVAL 1 MONTH"| mysql -h localhost -u [local_User] -p[local_Password] [local_DbName]

1 comment:

Shruti s said...

Ohhh… nice informative and unique blog copy the records from remote server to local server.
Thank you for sharing.
Web Design Company Bangalore | Website Development services in Bangalore | Website Development Company in Bangalore | Software Development Company in Bangalore

Post a Comment