远程MySQL读取?
我有一个问题!是否可以从位于另一台服务器上的mysql数据库读取数据?
我有 CMS,它在本地服务器上的数据库中写入,我想从另一台服务器上读取该数据库中的新网页!
你能帮我吗?
嗯!
I have one question! Is it possible to read from mysql database located on another server?
I have CMS which writes in database on local server, and I want to read with new web page from this database from another server!
Can you please help me?
Tnx!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
在为数据库指定的连接参数中,只需添加主机或主机名参数。您必须检查 CMS 文档以了解如何准确指定这一点。
In your connection parameters that you specify for the database just add the host or hostname parameter. You'll have to check the documentation for the CMS to see how to exactly specify this.
在
/etc/mysql/my.cnf
(在 unix 系统上)上,注释该行:并且您应该能够从任何地方连接。请注意,您可能需要在防火墙规则中允许流向该端口的流量。
on
/etc/mysql/my.cnf
(on unix system), comment the line:and you should be able to connect from anywhere. Note that you may need to allow traffic to that port in your firewall rules.
如果您的 CMS 和 MySQL 机器在网络上相互开放,那么只要您知道数据库机器的主机名和凭据,您就没有理由不能使用不同的机器。
If your CMS and MySQL boxes are open to each other on the network, there's no reason why you can't use a different box, providing you know the database box's hostname and credentials.
是的,这是可能的。连接时只需添加 MySQL 机器的主机名而不是 localhost 即可。
这需要三件事:
Yes, it's possible. Just add the hostname of the MySQL machine instead of localhost when connecting.
This requires three things:
MySQL 可以通过 TCP/IP 进行连接。如果您对数据库服务器 D 进行了这样的配置,则客户端 C 可以从任何地方连接到它。在大多数系统上,默认情况下 D 只允许本地连接、本地客户端。请参阅“GRANT”文档了解如何授予客户端远程连接的权限。
MySQL 也可以复制。这意味着您有多个数据库服务器,这可以确保它们之间的数据始终是最新的。显然这比听起来要困难得多:)。通常,您将设置某种主从复制:主数据库允许写入,并且它将确保在不久的将来,其所有从数据库都会获得最新的数据。然后,客户端可以从任何服务器读取数据,无论是从服务器还是主服务器。
MySQL can connect over TCP/IP. If you have database server D configured as such, then Client C can connect to it from anywhere. On most systems, by default D will only allow local connections, local clients. Please refer to the "GRANT" documentation on how to grant clients the right to connect from remote.
MySQL can also replicate. Meaning you have several database servers, which make sure that between them, the data is always up-to-date. Obviously this is much harder then it might sound :). Usually, you will set up some sort of master-slave replication: A master database allows writing to, and it will make sure that sometime soon, all its slaves get the newest data past along. clients can then read from any server, be it slave or master.