Connecting file to phpMyAdmin error

时间:2017-12-18 05:46:11

标签: php html css

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):

$mysqli = new 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:

Warning: mysqli::__construct(): (HY000/2002): Connection refused in /opt/lampp/htdocs/form.php on line 6

if this is not enough information, I am sorry but I am new.

2 个答案:

答案 0 :(得分:0)

PHP expects to use port 3306 for MySQL. So you need to open XAMPP, and change the XAMPP MySQL port to 3306, then restart the MySQL server.

答案 1 :(得分:0)

停止Xampp

打开xampp / mysql / bin / my.ini

将MySQL端口编辑为3306

重新启动Xampp

我说它已经设置为3306所以只需检查它当前设置的内容并将PHP / phpMyAdmin中的设置更新为3306而不是8080. 8080通常用于网络服务器。