简体   繁体   English

IIS无法连接到远程数据库

[英]IIS Can't connect to remote database

I have a website on IIS and want to access a database on a remote host. 我在IIS上有一个网站,想要访问远程主机上的数据库。

my code: 我的代码:

$this->db = new mysqli($hostname, $username, $password, $dbname);

I get this error: 我收到此错误:

Es konnte keine Verbindung hergestellt werden, da der Zielcomputer die Verbindung verweigerte Es konnte keine Verbindung Hergestellt werden,da der Zielcomputer die Verbindung verweigerte

In english its like 用英语说

Remote Host refused connection 远程主机拒绝连接

Default Port is 3306, when I execute 当我执行时,默认端口为3306

$this->db = new mysqli($hostname, $username, $password, $dbname, 3306);

I get the same result. 我得到相同的结果。

Via cmd telnet I can't connect to $hostname 3306, but to $hostname 1433. 通过cmd telnet我无法连接到$ hostname 3306,但是可以连接到$ hostname 1433。

So I tried 所以我尝试了

$this->db = new mysqli($hostname, $username, $password, $dbname, 1433);

But this isn't working either. 但这也不起作用。 I get 我懂了

mysqli::__construct(): MySQL server has gone away mysqli :: __ construct():MySQL服务器不见了

mysqli::__construct(): Error while reading greeting packet. mysqli :: __ construct():读取问候数据包时出错。 PID=3276 PID = 3276

Do you know how I can get the connection to the database? 您知道我如何获得与数据库的连接吗?

Based on the info in your question, it looks like the remote database is SQL Server, not MySQL. 根据您问题中的信息,看起来远程数据库是SQL Server,而不是MySQL。 Therefore you need to use PHP's MSSQL library: http://php.net/manual/en/book.mssql.php 因此,您需要使用PHP的MSSQL库: http : //php.net/manual/zh/book.mssql.php

It usually requires additional installation/configuration though. 不过,它通常需要其他安装/配置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM