PHP doesn't know the correct path to mysql.sock
Moderator: General Moderators
PHP doesn't know the correct path to mysql.sock
Hi folks,
I have installed mysql but I had to change the default datadir to /mysqldb. I also had to change the default socket path to /mysqldb/mysql.sock.
Everything works fine with the clients, I can use mysql and other win32 clients to connect to mysql server and everything is working smoothly.
However, when running a php page which connect to my mysql database, it returns me an error looking for mysql.sock in /var/lib/mysql. It obviously won't work because I have changed the default socket path to /mysqldb!
How could I tell php to look in /mysqldb.
I'm not sure to have used to correct method to move the datadir to another place on the system... there must be a 'standard' procedure to do so?
Two solutions required :
1. Changing the Mysql datadir correctly
2. Tell php to look in /mysqldb for mysql.sock
Any ideas?
Thanks in advance,
Best regards,
Steve
I have installed mysql but I had to change the default datadir to /mysqldb. I also had to change the default socket path to /mysqldb/mysql.sock.
Everything works fine with the clients, I can use mysql and other win32 clients to connect to mysql server and everything is working smoothly.
However, when running a php page which connect to my mysql database, it returns me an error looking for mysql.sock in /var/lib/mysql. It obviously won't work because I have changed the default socket path to /mysqldb!
How could I tell php to look in /mysqldb.
I'm not sure to have used to correct method to move the datadir to another place on the system... there must be a 'standard' procedure to do so?
Two solutions required :
1. Changing the Mysql datadir correctly
2. Tell php to look in /mysqldb for mysql.sock
Any ideas?
Thanks in advance,
Best regards,
Steve
php.ini:
Code: Select all
//...skipped
mysql.default_socket "/mysqldb/mysql.sock"
//...skippedPHP manual wrote: The default location of php.ini is a compile time option (see the FAQ entry), but can be changed for the CGI and CLI version with the -c command line switch, see the chapter about using PHP from the command line. You can also use the environment variable PHPRC for an additional path to search for a php.ini file.
Code: Select all
$ locate php.ini
/usr/local/Zend/etc/php.ini
/usr/local/lib/php.ini
/usr/local/lib/php.ini.bak
/usr/local/src/php-4.3.3/pear/tests/php.ini
/usr/local/src/php-4.3.3/php.ini-dist
/usr/local/src/php-4.3.3/php.ini-recommended- mrvanjohnson
- Forum Contributor
- Posts: 137
- Joined: Wed May 28, 2003 11:38 am
- Location: San Diego, CA
Or if you have a phpinfo page i.e.
You can look at the first section where it says
Code: Select all
<?php
phpinfo () ;
?>This is tell you which php.ini file your webserver is using in case you find mulitple copies.Configuration File (php.ini) Path
I edited /etc/php.ini
; Default socket name for local MySQL connects. If empty, uses the built-in
; MySQL defaults.
mysql.default_socket = /mysqldb/mysql.sock
But that didn't change anything, php is still looking for the mysql socket in /var/lib/mysql/ ... that's wierd!
I keep searching ...
Thanks
Steve
; Default socket name for local MySQL connects. If empty, uses the built-in
; MySQL defaults.
mysql.default_socket = /mysqldb/mysql.sock
But that didn't change anything, php is still looking for the mysql socket in /var/lib/mysql/ ... that's wierd!
I keep searching ...
Thanks
Steve
Okay, I'm on a good track...
Take a look at my phpinfos : http://badside.homeunix.org/grip/info.php
The socket is /var/lib/mysql/mysql.sock, even if I specified /mysqldb/mysql.sock in the php.ini file.
How could I change this system-wide?
Thanks again!
Steve
Take a look at my phpinfos : http://badside.homeunix.org/grip/info.php
The socket is /var/lib/mysql/mysql.sock, even if I specified /mysqldb/mysql.sock in the php.ini file.
How could I change this system-wide?
Thanks again!
Steve
Code: Select all
Name local master
mysql.default_socket no value no value