trouble chanigng mysql 5 socket location

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

How do I change the place where the mysql socket file gets created?  I
thought it was in the my.cnf file by changing the "socket" property.
However, using MySQL 5.0 on my Fedora Core 5 Linux system, when I do
this and restart, attempting to connect to MySQL through PHP gives me
this error

Warning: mysql_connect() [function.mysql-connect]: Can't connect to
local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) in
/usr/local/apache2/htdocs/refillingstation/db.php on line 19
Can't connect to MySQL: 'Can't connect to local MySQL server through
socket '/var/lib/mysql/mysql.sock' (2)'

Here is my "my.cnf" file:

# Default to using old password format for compatibility with mysql 3.x
# clients (those using the mysqlclient10 compatibility package).



Thanks for any additional info. - Dave

Re: trouble chanigng mysql 5 socket location wrote:
Quoted text here. Click to load it

Both server and client (the client in this case being a PHP application)
need to agree on the location of the socket file.  So you also need to
change the location PHP is expecting to find the socket file.

You can do this by editing the php.ini that your web server is using.
Find out the location by running a web page containing "<?php phpinfo();
?>"  Edit that php.ini file, and look for an entry
"mysql.default_socket" or "mysqli.default_socket" depending on whether
you are using the mysql or mysqli API.

Or you can skip the php.ini editing step if you use the socket location
in every mysql_connect() call you make in your PHP applications.  You
can specify the socket file location explicitly:

   $link = mysql_connect("localhost:/tmp/mysql5.sock", "user", "password");
   if (!$link) { die('Could not connect: ' . mysql_error()); }

See for more

Bill K.

Site Timeline