简体   繁体   English

将文件连接到phpMyAdmin错误

[英]Connecting file to phpMyAdmin error

This problem I am having trouble with, I have been looking at it for a few hours now. 我遇到了这个问题,已经研究了几个小时。 So basically I am working on a registration form on my website, and while working on the php, I connected it to MySQL and Database with this line of code (which is the 6th line of code): 因此,基本上,我正在网站上注册表格,在使用php时,我使用以下代码行(这是第六行代码)将其连接到MySQL和数据库:

$mysqli = new mysqli('localhost:8080', 'root', 'mypass123', 'accounts'); $ mysqli =新的mysqli('localhost:8080','root','mypass123','accounts');

I use Xampp on a Mac and when I try to register it works just not fully so, the problem is it shows this error: 我在Mac上使用Xampp,当我尝试注册Xampp时,它不能完全正常工作,因此问题是它显示了此错误:

Warning: mysqli::__construct(): (HY000/2002): Connection refused in /opt/lampp/htdocs/form.php on line 6 警告:mysqli :: __ construct():(HY000 / 2002):在第6行的/opt/lampp/htdocs/form.php中,连接被拒绝

if this is not enough information, I am sorry but I am new. 如果这还不够,我很抱歉,但是我是新手。

PHP expects to use port 3306 for MySQL . PHP希望对MySQL使用端口3306 So you need to open XAMPP, and change the XAMPP MySQL port to 3306, then restart the MySQL server. 因此,您需要打开XAMPP,并将XAMPP MySQL端口更改为3306,然后重新启动MySQL服务器。

Stop Xampp 停止Xampp

Open xampp/mysql/bin/my.ini 打开xampp / mysql / bin / my.ini

Edit MySQL port to 3306 将MySQL端口编辑为3306

Restart Xampp 重新启动Xampp

I'd say that it's already set to 3306 so just check what it's currently set to and update the setting in your PHP/phpMyAdmin to 3306 instead of 8080. 8080 is generally for the web server. 我想说它已经设置为3306,所以只需检查它当前设置为什么,并将PHP / phpMyAdmin中的设置更新为3306而不是8080。8080通常用于Web服务器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM