如何从不同的服务器连接到 mysql 数据库?

发布于 2024-09-04 06:40:22 字数 120 浏览 2 评论 0原文

比方说,我有一个根网站,在远程服务器上有 mysql 数据库。

我想从许多其他小网站(权限较低)连接到该特定数据库(以进行查询)。

这可以做到吗?

语言:jsp、java、php

I have, let's say, a root website with mysql db on a remote server.

I want to connect to that particular database (to make queries), from many other little websites (with lower priviledges).

Can this be done?

Language: jsp, java, php

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(5

铁憨憨 2024-09-11 06:40:23

如果MySQL服务器在你的控制之下,那并不困难;您可以找到该过程 这里。如果不是,你唯一能做的就是请求管理员这样做,否则这是不可能的。

If the MySQL server is under your control, it's not difficult; you can find the procedure here. If it's not, the only thing you can do is beg the admin to do it, otherwise it's impossible.

最佳男配角 2024-09-11 06:40:22

有什么特别的问题吗?只需在连接字符串中指定服务器地址而不是“localhost”。
您还可以为此创建具有最小权限的专用用户。

Any particular problem? Just specify server address instead of 'localhost' in connection string.
You can also create dedicated user with minimal privileges for that.

挽心 2024-09-11 06:40:22

默认配置通常包含一个变量

 skip-networking

,您需要注释掉该变量才能启用网络。

The default configuration often contains a variable

 skip-networking

which you need to comment-out in order to have networking enabled.

烟沫凡尘 2024-09-11 06:40:22

是的,可以做到,MySQL 允许来自远程主机的连接(假设 MySQL 配置为允许网络连接并假设远程主机已被授予)。如果出现问题,请参阅 5.4.7 部分。拒绝访问错误的原因列出了最常见的问题和解决方案。

Yes it can be done, MySQL allows connections from remote hosts (assuming MySQL is configured to allow network connections and assuming the remote hosts are granted). In case of problem, the section 5.4.7. Causes of Access-Denied Errors lists most common problems and solutions.

秋千易 2024-09-11 06:40:22

除了 Nikita Rybak 和 Pascal Thivent 的回答之外,我想指出的是,大多数托管提供商不允许从本地主机以外的位置进行查询。

我不知道您对服务器配置有多少访问权限,但是当我第一次开始尝试跨域/服务器的连接时,我会让自己感到头痛。

In addition to the answers from Nikita Rybak andPascal Thivent, I'd like to note that most hosting providers don't allow queries from locations other than localhost.

I don't know how much access you have to the server configuration, but I would have saved myself a headache a while back when I first started experimenting with connections across domains/servers.

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