mysqli::real_connect(): (HY000/2002): Connection refused

参考文章:https://www.louishe.com/2019/10/28/doc-5925.html

mysqli::real_connect(): (HY000/2002): Connection refused
 使用配置文件中定义的控制用户连接失败。
 mysqli::real_connect(): (HY000/2002): Connection refused

解决办法:

第一步:按照官方文档设置一次密码,设置参考 http://localhost/dashboard/faq.html

How can I make my XAMPP installation more secure?

By default, XAMPP has no passwords set and it is not recommended to run XAMPP with this configuration as it is accessible to others.

Simply type the following command (as root) to start a simple security check:

sudo /opt/lampp/lampp security

Now you should see the following dialog on your screen:

XAMPP: Quick security check...
XAMPP: MySQL is accessable via network.
XAMPP: Normaly that's not recommended. Do you want me to turn it off? [yes] yes
XAMPP: Turned off.
XAMPP: Stopping MySQL...
XAMPP: Starting MySQL...
XAMPP: The MySQL/phpMyAdmin user pma has no password set!!!
XAMPP: Do you want to set a password? [yes] yes
XAMPP: Password: ******
XAMPP: Password (again): ******
XAMPP: Setting new MySQL pma password.
XAMPP: Setting phpMyAdmin's pma password to the new one.
XAMPP: MySQL has no root passwort set!!!
XAMPP: Do you want to set a password? [yes] yes
XAMPP: Write the passworde somewhere down to make sure you won't forget it!!!
XAMPP: Password: ******
XAMPP: Password (again): ******
XAMPP: Setting new MySQL root password.
XAMPP: Setting phpMyAdmin's root password to the new one.
XAMPP: The FTP password for user 'nobody' is still set to 'lampp'.
XAMPP: Do you want to change the password? [yes] yes
XAMPP: Password: ******
XAMPP: Password (again): ******
XAMPP: Reload ProFTPD...
XAMPP: Done.

(1) Setting a password will protect the XAMPP demo pages (http://localhost/xampp/) using this password. The user name is ‘lampp’!

After running this command, your XAMPP installation should be more secure.

第二步:

把/opt/lampp/phpmyadmin路径下的config.inc.php文件,使用config.sample.inc.php文件代替。即把原先的 config.inc.php 文件备份,把 config.sample.inc.php 修改成 config.inc.php 。

config.sample.inc.php :

*******
/* Authentication type */
$cfg['Servers'][$i]['auth_type'] = 'cookie';
/* Server parameters */
$cfg['Servers'][$i]['host'] = 'localhost';
$cfg['Servers'][$i]['compress'] = false;
$cfg['Servers'][$i]['AllowNoPassword'] = false;
******

完成!

滚动至顶部