Home  >  Article  >  Database  >  Why am I Getting a \"#2002 cannot log in to the mysql server phpmyadmin\" Error?

Why am I Getting a \"#2002 cannot log in to the mysql server phpmyadmin\" Error?

Barbara Streisand
Barbara StreisandOriginal
2024-10-31 21:53:29588browse

Why am I Getting a

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!

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