0

谁能指出这是否有任何错误?有人告诉我有错误,我只能通过 localhost 连接,而不是通过这个主机名..

有人告诉我,我在 db.class.php 中设置的密码是错误的。部分代码如下所示。赞赏!

function __construct($hostname = "192.xx.x.45", $username = "test", $password = "tests", $database = "testing", $prefix = "prefix_", $connector = "mysqli") {
    $this->hostname = !empty($hostname) ? $hostname : "";
    $this->username = !empty($username) ? $username : "";
    $this->password = !empty($password) ? $password : "";
    $this->database = !empty($database) ? $database : "";
    $this->prefix = !empty($prefix) ? $prefix : "";
    $this->connector = !empty($connector) ? $connector : "mysqli";
}

if ($this->config->connector == "mysqli") { 
$this->connection = mysqli_connect($this->config->hostname, $this->config->username, $this->config->password);
$this->selectdb = mysqli_select_db($this->connection, $this->config->database);
}
4

1 回答 1

0

从您收到的错误消息来看,您的问题是您用于连接 MySQL 的数据库用户没有权限从您访问数据库的服务器的 IP 进行连接。

您需要修改您的数据库用户以允许它从任何 IP 连接到您的 MySQL 数据库,或者只是您的服务器的 IP。如前所述,请查看 MySQL 手册:

http://dev.mysql.com/doc/refman/5.0/en/account-names.html

此外,您需要确保 MySQL 服务器的防火墙允许从其他服务器连接到 MySQL 端口(默认为 3306)。

于 2013-06-05T09:14:41.200 回答