如何在php中从一个网站连接到另一个网站的数据库
如何在 php 中从一个网站连接到另一个网站的数据库?
How can I connect from one website to database of another website in php.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
如何在 php 中从一个网站连接到另一个网站的数据库?
How can I connect from one website to database of another website in php.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(2)
您可以在
config.php
中或存储它们的位置添加连接详细信息,以及another-website.com
或主机 URL 的 IP(您可能有localhost
),然后是用户名和密码。You add the connection details in
config.php
or where you store them, andanother-website.com
or the IP to the host url (You probably havelocalhost
there), then the username and the password.另一个网站将要求其端口开放供您连接。他们还需要数据库用户允许不仅仅来自本地计算机的连接。
如果您有相当标准的 LAMP 设置,这意味着在数据库服务器上打开端口 3306,以便可以进行外部连接,并且数据库用户设置将能够从外部世界进行连接。
请记住,它们可能是延迟问题。
The other website will require their port to be open for yours to connect to. They will also need the database user to allow connections that are not just from the local machine.
If you have a fairly standard LAMP set-up, this will mean opening port 3306 on the database server so outside connections can be made, and a database user setting up that will be able to connect from the outside world.
Bear in mind their may be latency issues.