简体   繁体   English

在线和本地主机数据库之间的MySQL数据同步

[英]MySQL data sync between Online and localhost databases

I have localhost(master) mysql database and need to get sync with online (slave) database; 我有localhost(master)mysql数据库,需要与在线(从属)数据库同步; ex:www.abc.com 例如:www.abc.com

  • currently im using manual data transferring by excel files. 目前,即时通讯使用的是由excel文件进​​行的手动数据传输。 but this way is difficult to maintain. 但是这种方式很难维护。

any suggestion please. 请提出任何建议。

thank you 谢谢

You can setup master slave replication. 您可以设置主从复制。 It copied automatically from a master to a slave database. 它自动从主数据库复制到从数据库。 Below link will be helpful to you. 以下链接将对您有所帮助。

https://www.digitalocean.com/community/tutorials/how-to-set-up-master-slave-replication-in-mysql https://www.digitalocean.com/community/tutorials/how-to-set-up-master-slave-replication-in-mysql

You could use following steps, everytime you need to Sync Slave with Master. 每当您需要将Slave与Master同步时,都可以使用以下步骤。 Your problem seems to be more related to data move on adhoc basis. 您的问题似乎与临时数据移动有关。

  1. Do export full database from Master. 从Master导出完整的数据库。

     mysqldump -u root-proot dbname > db_export.sql 
  2. Import the step-1 exported data into Slave. 将步骤1导出的数据导入到Slave中。

     mysql -uUsername -pPassword dbname < db_export.sql 
  3. Perform any environment settings if needed by systematic update/delete/insert. 如果需要,请通过系统更新/删除/插入来执行任何环境设置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM