如何仅知道前端 URL 连接到数据库?

发布于 2024-12-27 02:09:46 字数 669 浏览 0 评论 0原文

我有一个从前端访问数据库的 URL。

https://db.blabla.com

这些信息足以以编程方式连接到数据库吗?我正在尝试这样的事情(php):

<?php
$username = "xxx";
$password = "xxx";
$hostname = "db.blabla.com"; 

//connection to the database
$dbhandle = mysql_connect($hostname, $username, $password) 
  or die("Unable to connect to MySQL");
echo "Connected to MySQL<br>";
?>

并且似乎至少认识到主机存在,但它说连接超时。 似乎使用 tcp://

我也用 java 和 jdbc:mysql:// 进行了随机测试,但同样的问题。

我不知道协议和端口应该是什么...是否可以猜测,也许是反复试验...?

谢谢

编辑:服务器文件的文件结尾 .do 能否提示所使用的数据库类型?

编辑2:这不是一个php问题,我只是放了php示例。这是关于通常如何(如果可能)进行连接。

I have a URL from frontend access to the database.

https://db.blabla.com

Is this enough information to connect programmatically to the database? I'm trying with things like this (php):

<?php
$username = "xxx";
$password = "xxx";
$hostname = "db.blabla.com"; 

//connection to the database
$dbhandle = mysql_connect($hostname, $username, $password) 
  or die("Unable to connect to MySQL");
echo "Connected to MySQL<br>";
?>

And it seems at least to recognize that the host exists, but it says timed out connection.
It seems to use tcp://

I also did a random test with java and jdbc:mysql:// but same problem.

I don't have an idea what the protocol and port are supposed to be... is it possible to guess it, maybe trial and error...?

Thanks

Edit: Could file ending .do for server files give a hint for the type of database used?

Edit 2: This is not a php question, I just put php example. It's about how (if possible) generally connect.

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

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

发布评论

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

评论(1

白鸥掠海 2025-01-03 02:09:46

信息还不够。你不知道后端在做什么。可能有数据库,也可能没有。它可能是 MySQL,也可能不是。它可能位于同一主机上,也可能不是。它可能具有与前端相同的密码,但不应该。

任何称职的 DBA 都会配置数据库,因此只有运行前端的主机(可能还有其他一些授权主机)才能访问它。任何体面的网络管理员都会确保这些主机是防火墙允许访问数据库服务器的唯一主机。

It isn't enough information. You have no idea what the backend is doing. There might be a database, there might not be. It might be MySQL, it might not be. It might be on the same host, it might not be. It might have the same passwords as the front end, it shouldn't.

Any DBA worth his salt will have configured the database so only the host running the front end (and maybe a few other authorised hosts) can access it. Any decent network admin will have ensured that those hosts are the only ones that the firewall will allow access to the database server as well.

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