远程MySQL读取?

发布于 2024-11-01 15:04:07 字数 122 浏览 4 评论 0原文

我有一个问题!是否可以从位于另一台服务器上的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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

盗心人 2024-11-08 15:04:07

在为数据库指定的连接参数中,只需添加主机或主机名参数。您必须检查 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.

懒猫 2024-11-08 15:04:07

/etc/mysql/my.cnf (在 unix 系统上)上,注释该行:

bind-address            = 127.0.0.1

并且您应该能够从任何地方连接。请注意,您可能需要在防火墙规则中允许流向该端口的流量。

on /etc/mysql/my.cnf (on unix system), comment the line:

bind-address            = 127.0.0.1

and you should be able to connect from anywhere. Note that you may need to allow traffic to that port in your firewall rules.

暖心男生 2024-11-08 15:04:07

如果您的 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.

待"谢繁草 2024-11-08 15:04:07

是的,这是可能的。连接时只需添加 MySQL 机器的主机名而不是 localhost 即可。

这需要三件事:

  • MySQL 服务器允许远程连接
  • 没有防火墙阻止此流量(就像许多廉价 Web 主机上的情况一样)
  • 用户的 MySQL 权限配置为允许来自远程主机的连接(有时用户设置为 < em>user@localhost 在权限表中,这不允许该用户的所有远程连接)。

Yes, it's possible. Just add the hostname of the MySQL machine instead of localhost when connecting.

This requires three things:

  • The MySQL server allows remote connections
  • There's no firewall blocking this traffic (as is the case on many cheap web hosts)
  • The MySQL privileges on your user is configured to allow connection from remote hosts (sometimes the users are set to user@localhost in the privilege table, which disallows all remote connections for that user).
折戟 2024-11-08 15:04:07

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文