Page 1 of 1
PHP doesn't know the correct path to mysql.sock
Posted: Wed Dec 03, 2003 8:45 am
by shemond
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
Posted: Wed Dec 03, 2003 10:00 am
by Weirdan
php.ini:
Code: Select all
//...skipped
mysql.default_socket "/mysqldb/mysql.sock"
//...skipped
Posted: Wed Dec 03, 2003 10:14 am
by shemond
I don't have any php.ini file in /etc
My only main mysql config file is /etc/my.cnf
Where is your php.ini file located?
Posted: Wed Dec 03, 2003 10:55 am
by Weirdan
PHP 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
Posted: Wed Dec 03, 2003 11:06 am
by mrvanjohnson
Or if you have a phpinfo page i.e.
You can look at the first section where it says
Configuration File (php.ini) Path
This is tell you which php.ini file your webserver is using in case you find mulitple copies.
Posted: Wed Dec 03, 2003 11:26 am
by Chambrln
Depending on your system and how you installed php it doesn't always automatically create a php.ini file. You might need to copy the php-dist.ini to the correct file and rename it to php.ini as well as make any necessary changes. I had this problem on a redhat box I installed php on.
Posted: Wed Dec 03, 2003 11:58 am
by shemond
Thanks for the help to you guys,
In fact, I've installed mysql and php on a Redhat9 box.
I'll try this when at home, thanks!

Posted: Wed Dec 03, 2003 12:12 pm
by shemond
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
Posted: Wed Dec 03, 2003 12:18 pm
by shemond
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
Posted: Wed Dec 03, 2003 12:23 pm
by shemond
OK, DONE!
I made that issue more complex than it actually is.
I only pointed datadir to /mysqldb
The socket is now back in /var/lib/mysql/ so EVERYTHING linked to mysql will be working smoothly.
Thanks to all again for your help!
Steve
Posted: Wed Dec 03, 2003 12:28 pm
by Weirdan
Code: Select all
Name local master
mysql.default_socket no value no value
did you restart apache?