Home  >  Article  >  Backend Development  >  How to Fix \"mysqli_real_connect(): (HY000/2002): No such file or directory\" Error in phpMyAdmin for MacOS?

How to Fix \"mysqli_real_connect(): (HY000/2002): No such file or directory\" Error in phpMyAdmin for MacOS?

Susan Sarandon
Susan SarandonOriginal
2024-10-19 16:30:03691browse

How to Fix

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn