PHPMyAdmin MySQL connection problem using localhost

After setting up multiple PHP versions in LAMP, I tried to open localhost/phpmyadmin in a browser with Username: root and the password that I had previously used, before the PHP changes. The log-in failed with the message:

mysqli_real_connect(): (HY000/2002): No such file or directory

However, using 127.0.0.1/phpmyadmin the log-in is successful.

Although I am not sure why this issue has only happened after the changes, it appears to depend on the host name in the /etc/webapps/phpmyadmin/config.inc.php in the line:

$cfg['Servers'][$i]['host'] = 'localhost';

The mysqli_connect method requires a working socket of the database using the IP address of the DB host along with the port number.
If ‘localhost’ is set as the value, there is no port number.
To use TCP/IP networking, use an IP address or hostname such as 127.0.0.1 so line line should be changed to:

$cfg['Servers'][$i]['host'] = '127.0.0.1';

This should prevent connection problems.

 

Documentation prepared by Victor

Calogero Scarnà
Calogero Scarnà
Articoli: 299

Newsletter

Inserisci il tuo nome e il tuo indirizzo email qui sotto e iscriviti alla nostra newsletter