这是用于连接到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连接文件错误
发布评论