Unable to Access phpMyAdmin with #2002 MySQL Login Error
When attempting to access phpMyAdmin, you may encounter the perplexing error message "#2002 cannot log in to the mysql server phpmyadmin." This issue can stem from an incorrect server address setting in phpMyAdmin's configuration file.
Troubleshooting the Error
To resolve this problem, navigate to the phpMyAdmin configuration file, config.inc.php, and locate the server host setting:
<code class="php">$cfg['Servers'][$i]['host'] = 'localhost';</code>
Solution:
Modify the host address to '127.0.0.1' instead of 'localhost':
<code class="php">$cfg['Servers'][$i]['host'] = '127.0.0.1';</code>
This change ensures that phpMyAdmin attempts to connect to the MySQL server on the local machine, resolving the #2002 error.
Note for Fresh Installs:
If you have just installed phpMyAdmin, you may not find the config.inc.php file because it is initially named config.sample.inc.php. Simply rename the latter to config.inc.php and apply the modification as mentioned above.
The above is the detailed content of Why am I Getting a \"#2002 cannot log in to the mysql server phpmyadmin\" Error?. For more information, please follow other related articles on the PHP Chinese website!