trouble chanigng mysql 5 socket location

Hi,

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:

[mysqld]
datadir=/var/lib/mysql
socket=/tmp/mysql5.sock
# Default to using old password format for compatibility with mysql 3.x
# clients (those using the mysqlclient10 compatibility package).
old_passwords=1

[mysql.server]
user=mysql
basedir=/var/lib

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid


Thanks for any additional info. - Dave
laredotornado [ Do, 05 Oktober 2006 16:22 ] [ ID #1489800 ]

Re: trouble chanigng mysql 5 socket location

laredotornado [at] zipmail.com wrote:
> 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.

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 http://www.php.net/manual/en/function.mysql-connect.php for more
details.

Regards,
Bill K.
Bill Karwin [ Do, 05 Oktober 2006 17:20 ] [ ID #1489802 ]
Datenbanken » mailing.database.mysql » trouble chanigng mysql 5 socket location

Vorheriges Thema: Error 1305 - trying to execute User Defined Function
Nächstes Thema: string comparisons with case