【发布时间】:2017-06-29 02:04:18
【问题描述】:
这是用于连接 phpMyAdmin 数据库的 connection.php 文件
<?php
require_once 'config.php';
class DB_Connection {
private $connect;
function __construct() {
$this->connect = mysqli_connect(hostname, user, password, db_name)
or die("Could not connect to db");
}
public function getConnection()
{
return $this->connect;
}
}
?>
但是当我尝试使用 Postman 发帖时,我似乎收到了这个错误
<br />
<b>Warning</b>: mysqli_connect(): (HY000/1130): Host '192.168.98.178' is not allowed to connect to this MariaDB server in
<b>/Applications/XAMPP/xamppfiles/htdocs/connection.php</b> on line
<b>8</b>
<br />
Could not connect to db
【问题讨论】:
-
SELECT user, host FROM mysql.user。我打赌没有列出 192.168.98.178 或(任何变体)。您需要在正确的主机上添加您的用户。 -
在我的 SQL 中,我有 SELECT * FROM
users,我将如何将用户添加到主机? -
您不需要,您需要添加您在 mysqli_connect 中使用的 your 用户凭据。
-
我在哪里做这个对不起!对不起,如果它很简单,但我以前没有这样做过!!!