phpmyadmin 同步
我在网络酒店上有一个远程服务器,我想与本地服务器同步。
我的计划是通过主从关系来执行此操作,但网络主机作为虚拟服务器运行,所以问题一是,是否可以将我的服务器部分设置为主服务器? (主机对此不太了解)
我的另一个但不太棒的想法是通过主机或本地服务器上的 phpmyadmin 手动同步(它们都运行 mysql/phpmyadmin,但我更喜欢如果我可以从本地同步到主机) )
当我尝试从主机或本地同步时,出现以下错误:
“无法连接到目标/源”
我该如何解决这个问题?我是数据库互连的新手,所以我是否必须在本地或远程的任何地方启用任何功能?
I have a remote server on webhotel which i want to synchronize with my local server.
My plan was to either do this though the master - slave relation but the webhost is running as a virtual server, so question one is, is it possible to set my portion of the server up to master server? (The host didnt know much about this)
My other but less awesome idea was to manually synchronize through phpmyadmin on either the host or the local server (They are both running mysql/phpmyadmin, but i would prefer if i could sync from local to host)
When i try to sync either from host or from local i get the following error:
"Cannot connect to target/source"
How do I get around this? I am a novice with DB interconnections so do i have to enable anything anywhere on either local or remote?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您似乎在这里遇到了一些问题,
超时
我将从这里开始,因为您可能遇到权限问题。我建议首先确保您的本地 IP 地址有权连接到远程 MySQL 数据库,反之亦然,根据您的设置,您可以在 phpMyAdmin、托管控制台(例如 cPanel)或通过 shell 访问进行配置。我建议设置一个单独的用户,并使用强密码进行远程访问。
您的本地互联网连接上应该有一个静态 IP 地址,如果没有,请联系您的互联网服务提供商并安排一个。
在 phpMyAdmin 中,如果您有足够的访问权限,请通过“用户权限”选项卡并在“登录信息”下设置“主机”。出于明显的安全原因,我不会推荐“任何主机”设置。
在 cPanel 中的“数据库”下,您应该找到“远程 mySQL”,您可以在其中设置 IP 地址。
最后在 SSH 中,
注意:我建议将两个 mySQL 安装设置为远程访问。
我现在建议通过在本地计算机上运行一个小脚本来测试这一点,例如
注意:数据库中应该有数据,脚本才能正常工作,没有数据的结果将显示一条消息,表明脚本无法检索数据,这仍然会确定您现在是否有权访问数据库,但不能确保它 100% 可操作。
主或从
是的,这是可能的,只要您有足够的访问权限
在 phpMyAdmin 中:
这应该会设置您的复制。
同步
如果所有其他方法均失败,则在 phpMyAdmin 中转到“同步”选项卡,输入信息即可离开,您只需在下一页上确认同步,2 秒后即可完成了,就是这么简单。
对于生产服务器,我个人有一个主/从复制设置,但对于开发,当我需要“实时”数据来复制错误或问题时,我会进行同步,这是因为我只需要每 6-12 个月同步一次。如果我需要本地实时数据,那么我会设置主/从复制
You seem to have a couple of issues here,
TIME OUT
I would start here as you may have a permissions problem. I would recommend first ensuring that your local IP address has permission to connect to your remote mySQL database and vice versa, depending on your setup you may be able to configure this in phpMyAdmin, a hosting consule such as cPanel or via shell access. I would suggest setting up a separate user with a strong password for remote access.
You should have a static IP address on your local internet connection, if you do not have one contact your Internet Service Provider and arrange one.
In phpMyAdmin, if you have sufficient access, via the "user privileges" tab and setting the "host" under "login information". I would not recommend the "any host" setting for obvious security reasons.
In cPanel, under "databases" you should find "remote mySQL" where you can set your IP address.
Finally in SSH,
NOTE: I would recommend setting up both mySQL installations for remote access.
I would now recommend testing this by running a small script on your local machine, something like
NOTE: you should have data in the database for the script to work correctly, a result with no data will display a message that the script could not retrieve the data, this will still establish if you now have access to the database or not but doesn't ensure it is 100% operational.
MASTER OR SLAVE
Yes, it is possible, providing you have sufficient access
In phpMyAdmin:
This should set up your replication.
SYNCHRONIZE
If all else has failed then in phpMyAdmin go to the "synchronize" tab, enter the information and away you go, you just need to confirm the sync on the next page and 2 seconds later you're done, it is that easy.
For production servers I personally have a master/slave replication set-up but for development I sync when I need "live" data to replicate an error or problem, this is because I only need to sync once every 6-12 months. If I need live data locally then I would set up the master/slave replication