FAQ 2.3

From PmaWiki

Jump to: navigation, search

Contents

[edit] The error message "Warning: MySQL Connection Failed: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (111) ..." is displayed. What can I do?

You need to locate the correct location of your MySQL socket file, usually mysql.sock and configure your PHP or phpMyAdmin with this path.

For Red Hat users the path is most likely /var/lib/mysql/mysql.sock. Debian users will probably find it in /var/run/mysqld/mysqld.sock

[edit] Find the correct path

First, you need to determine what socket is being used by MySQL. From the mysql command-line client, type status and look for the line UNIX Socket.

Alternate method of locating the mysql-sock file:

$ find / -name mysql.sock

or if that fails,

$ find / -name *sock*

[edit] Verify the correct permissions

Please also make sure that the permissions of this file are such that it is readable by your webserver (i.e. '0755').

$ chmod 755 /tmp/mysql.sock

[edit] Tell PHP where to find the file

In your php.ini you will find a line like

mysql.default_socket = /tmp/mysql.sock

Set that to the correct path to the file and restart your Apache HTTP server.

[edit] Tell phpMyAdmin to use the default socket

config.inc.php allows you to over-ride the default PHP socket. Since we just configured PHP's socket correctly, completely remove the line $cfg['Servers'][$i]['socket'] from config.inc.php

Have also a look at the corresponding section of the MySQL documentation.


Thanks to Harald Legner and Brad Ummer for their work in documenting this.

Advertisement