Jump to content

[SOLVED] changing default mysql socket for php


Recommended Posts

I just compiled php 5.2.3 and it's trying to connect to mysql with socket /tmp/mysql.sock

But the actual socket is /var/run/mysqld/mysqld.sock (as set in my.cnf) . So my php apps (including phpmyadmin) can't find the socket

I can temporarily fix this by putting a symlink in /tmp ... "ln –s /var/run/mysqld/mysqld.sock /tmp/mysql.sock" ... everything works until I reboot, then the symlink is deleted - because it's in the temporary directory.


I think what I need to do is change the default socket php uses to /var/run/mysqld/mysqld.sock.

I tried changing the setting in php.ini (both CLI and Apache2) to: mysql.default.socket = /var/run/mysqld/mysqld.sock

But that didn't change anything. Phpinfo still showed: MYSQL_SOCKET = /tmp/mysql.sock


Does anybody know what I'm missing. Help really appreciated.





My environment:

Ubuntu 6.10 (Edgy)

php 5.2.3 (compiled myself: config options: --with-apxs2 --with-openssl=/usr/local/ssl

--with-curl –-with-mysql –enable-sockets –enable-soap)

mysql 5.0.45


Link to comment
Share on other sites

Hi. Thanks for the reply. Sorry, that was my typo: I'm using mysql.default_socket in php.ini. I've also restarted (and rebooted) several times.

This is becoming a real pain, because my symlink gets deleted from the tmp directory not just at reboot, but when there's been no activity on mysql for a while.

Link to comment
Share on other sites

  • 3 weeks later...

Solved it!

My php.ini file wasn't even being loaded, so the mysql.default_socket wasn't being set to where I wanted.

I set the PHPRC environment variable to PHPRC=/etc/php5/apache2 .... and everything now works. (I'm on Ubuntu, so did this in /etc/init.d/apache2).

Link to comment
Share on other sites

This thread is more than a year old. Are you sure you have something important to add to it?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.