邮递员中的PHP连接文件错误 [英] Php Connection File Error in Postman

查看:114
本文介绍了邮递员中的PHP连接文件错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是用于连接到phpMyAdmin数据库的connection.php文件

 <?php 
require_once'config.php';

class DB_Connection {

private $ connect;
函数__construct(){
$ this-> connect = mysqli_connect(主机名,用户,密码,db_name)
或die(无法连接到db);

}

公共功能getConnection()
{
return $ this-> connect;
}
}
?>

但是当我尝试用邮递员发帖时,我似乎收到此错误

 < br /> 
< b>警告< / b> ;: mysqli_connect():(HY000 / 1130):主机'192.168.98.178'不允许连接到
< b> / Applications中的此MariaDB服务器/XAMPP/xamppfiles/htdocs/connection.php</b>在线
< b> 8< / b>
< br />
无法连接到数据库


解决方案

设置是这里的关键。您正在使用XAMPP的MySQL服务器,对吗?我认为您是基于先前的问题。您要传递的主机名,用户名,密码和db_name是什么?



XAMPP的Mysql服务器默认具有root用户和空密码。因此,使用user ='root'和password =''应该可以吸引您。虽然对生产不利,但同时可以帮助您进行设置。



<过去,了解MySQL及其管理方法是一个好主意。 http://www.mysqltutorial.org/


This is the connection.php file being used to connect to a phpMyAdmin database

<?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;
        }
    }
    ?>

But i seem to get this error when i try to post with 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

解决方案

Knowing your setup is key here. You're using XAMPP's MySQL server, right? I think you are based on your previous question. What are you passing in for hostname, user, password, and db_name?

XAMPP's Mysql server has a root user and an empty password by default. So having user = 'root' and password = '' should work to get you in. Not good for production, but it'll help you get set up in the meantime.

Past that, learning about MySQL and how to manage it is a good idea. http://www.mysqltutorial.org/

这篇关于邮递员中的PHP连接文件错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆