mysql 导入/导出
我正在尝试创建一个自动进程来同步两台服务器的数据库。一个站点是实时的,我需要测试环境经常与实时站点同步(我正在考虑为此使用 cron 作业)。
我怎样才能实现这个?
I am trying to create an automatic process which will synchronize the databases of two servers. One site is live, and I need the testing environment to sync up with the live site every so often (I am thinking a cron job for that).
How can I implement this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
让系统保持最新
您可以通过 MySQL 复制http://dev .mysql.com/doc/refman/5.0/en/replication.html
您基本上正在查看主从配置
如果您想要更简单的东西,您可以使用 mysqldump 转储数据库,然后ssh 通过网络传送它,mysql 再次加载它。
在进行传输之前,您必须清除 mytestdatabase,但如果您正在寻找一个命令来“同步”数据库,这将做到这一点。
You can keep the systems up to date with MySQL replication
http://dev.mysql.com/doc/refman/5.0/en/replication.html
You are basically looking at a Master-Slave configuration
If you'd like something a little simpler, you can use mysqldump to dump your database, then ssh to ship it over the wire, and mysql to load it in again.
You will have to purge mytestdatabase before doing the transfer, but if you are looking for a single command to 'synchronize' database, this will do it.