php 使用 phpMyAdmin 同步 MySQL 远程和本地数据库
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14661501/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Synchronize MySQL remote & local database using phpMyAdmin
提问by ????? ???
I have local MySQL database which changes occasionally, when it changes I want to synchronize it with Remote database. I am using PhpMyAdmin's synchronize option for it.
我有本地 MySQL 数据库,它偶尔会发生变化,当它发生变化时,我想将它与远程数据库同步。我正在使用 PhpMyAdmin 的同步选项。
I have given permissions to all IP to connect remotely.
我已授予所有 IP 远程连接的权限。
Problem:When I want to synchronize remote database with local database using synchronize option of PhpMyAdmin. It only shows the database structure difference but data is also different on both the databases but it is not showing that difference.
问题:当我想使用 PhpMyAdmin 的同步选项将远程数据库与本地数据库同步时。它仅显示数据库结构差异,但两个数据库上的数据也不同,但并未显示该差异。
And when I synchronize the database by clicking Synchronize Databasebutton and again do synchronization. It again shows same structure synchronization.
当我通过单击Synchronize Database按钮同步数据库并再次进行同步时。它再次显示了相同的结构同步。
See image below

见下图

If anyone have alternate solution for it please also tell that. Local DetailsOS: Windows7 Software: EasyPHP12.0 Remote DetailsServer: Linux Cpanel PhpMyAdmin
如果有人有替代解决方案,请也告诉我。 本地详细信息操作系统:Windows7 软件:EasyPHP12.0 远程详细信息服务器:Linux Cpanel PhpMyAdmin
回答by K-Gun
Open phpMyAdmin/config.inc.phpand add these lines about "Server Configuration".
打开phpMyAdmin/config.inc.php并添加有关“服务器配置”的这些行。
$i++;
$cfg['Servers'][$i]['host'] = '<remote-server-address>'; // Remote MySQL hostname or IP address
$cfg['Servers'][$i]['port'] = ''; // MySQL port - leave blank for default port
$cfg['Servers'][$i]['socket'] = ''; // Path to the socket - leave blank for default socket
$cfg['Servers'][$i]['connect_type'] = 'tcp'; // How to connect to MySQL server ('tcp' or 'socket')
$cfg['Servers'][$i]['extension'] = 'mysql'; // The php MySQL extension to use ('mysql' or 'mysqli')
$cfg['Servers'][$i]['compress'] = FALSE; // Use compressed protocol for the MySQL connection
$cfg['Servers'][$i]['auth_type'] = 'config'; // Authentication method (config, http or cookie based)?
$cfg['Servers'][$i]['user'] = '<db-username>'; // Remote MySQL user
$cfg['Servers'][$i]['password'] = '<db-password>'; // Remote MySQL password
Now there is a 'servers' dropdown on your phpMyAdmin front page. Pick your sever and bingo!
现在,您的 phpMyAdmin 首页上有一个“服务器”下拉菜单。选择你的服务器和宾果游戏!
Credits: codejourneymen
And, there are a lot of example, maybe help:
而且,有很多例子,也许有帮助:
回答by Devart
My answer is not related to PhpMyAdmin, but anyway, let me recommend you Schema/Data comparison toolsin dbForge Studio for MySQL. These tools will help you to find, view differences and synchronize two databases.
我的回答与 PhpMyAdmin 无关,但无论如何,让我向您推荐dbForge Studio for MySQL 中的架构/数据比较工具。这些工具将帮助您查找、查看差异并同步两个数据库。
If you do not have access to remote database, then you may use HTTP tunnel connection, or use SSL/SSH security connection.
如果您无权访问远程数据库,那么您可以使用 HTTP 隧道连接,或者使用 SSL/SSH 安全连接。
回答by Subodh Ghulaxe
Try using SQLyog Job Agent (SJA) On Windows, it's available with the award-winning MySQL GUI SQLyog. The Linux version of SJA is free, and can be downloaded from webyog.com
尝试使用 SQLyog Job Agent (SJA) 在 Windows 上,它可与屡获殊荣的 MySQL GUI SQLyog 一起使用。SJA 的 Linux 版本是免费的,可以从 webyog.com 下载
回答by Savvy Aaron
While creating tables I would let the remote server to use even numbers and let local server to add odd numbers for auto increment. Then have a script to pull or push data between servers without any duplicate problems.
在创建表时,我会让远程服务器使用偶数,并让本地服务器添加奇数以进行自动递增。然后有一个脚本来在服务器之间拉取或推送数据,而不会出现任何重复的问题。
回答by Jim Miller
I don't understand why you would not just update the remote and ditch the local DB all together. Suggestion: You might want to set up two remotes - EX: dev.domain.com, www.domain.com. link local code to the dev and update/test then when you want to go to production just data dump dev on www DB. Safe and fallback ready when local DB goes down.
我不明白为什么你不只是更新遥控器并一起抛弃本地数据库。建议:您可能需要设置两个遥控器 - 例如:dev.domain.com、www.domain.com。将本地代码链接到开发人员并更新/测试,然后当您想要进行生产时,只需在 www DB 上进行数据转储开发。当本地数据库出现故障时,安全和后备准备就绪。

