trouble chanigng mysql 5 socket location

trouble chanigng mysql 5 socket location

am 05.10.2006 16:22:26 von laredotornado

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

Re: trouble chanigng mysql 5 socket location

am 05.10.2006 17:20:14 von Bill Karwin

laredotornado@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 " ?>" 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.