Home >Backend Development >PHP Tutorial >How to Fix \'mysqli_real_connect(): (HY000/2002): No such file or directory\' Error in phpMyAdmin for MacOS?
Resolving "mysqli_real_connect(): (HY000/2002): No such file or directory" Error in phpMyAdmin for MacOS
The "mysqli_real_connect(): (HY000/2002): No such file or directory" error in phpMyAdmin for MacOS occurs when PHP cannot establish a connection to the MySQL server. This issue arises when phpMyAdmin attempts to use localhost as the hostname for the MySQL server connection.
Solution:
To resolve this error, replace localhost with 127.0.0.1 in the phpMyAdmin configuration file (/etc/phpmyadmin/config.inc.php):
<code class="php">$cfg['Servers'][$i]['host'] = '127.0.0.1';</code>
By using 127.0.0.1, phpMyAdmin will establish a TCP connection to the MySQL server instead of attempting to use the mysql.socket, which is not available on MacOS.
The above is the detailed content of How to Fix \'mysqli_real_connect(): (HY000/2002): No such file or directory\' Error in phpMyAdmin for MacOS?. For more information, please follow other related articles on the PHP Chinese website!