邮递员中的PHP连接文件错误

编程入门 行业动态 更新时间:2024-10-23 12:34:20
本文介绍了邮递员中的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及其管理方法是一个好主意。 www.mysqltutorial/

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. www.mysqltutorial/

更多推荐

邮递员中的PHP连接文件错误

本文发布于:2023-10-29 08:02:18,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1539157.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:邮递员   错误   文件   PHP

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!