Bug 60515 - php-mysql-4.0.6-12 looks for mysql.sock in wrong location
Summary: php-mysql-4.0.6-12 looks for mysql.sock in wrong location
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: php   
(Show other bugs)
Version: 7.2
Hardware: i386 Linux
Target Milestone: ---
Assignee: Phil Copeland
QA Contact: David Lawrence
: 60542 60623 60731 60739 60749 60774 60840 61401 61619 (view as bug list)
Depends On:
TreeView+ depends on / blocked
Reported: 2002-02-28 21:09 UTC by Mark Cornick
Modified: 2014-01-21 22:48 UTC (History)
6 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2002-03-03 17:48:30 UTC
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

Description Mark Cornick 2002-02-28 21:09:14 UTC
From Bugzilla Helper:
User-Agent: Mozilla/4.77 [en] (X11; U; SunOS 5.7 sun4u)

Description of problem:
php-mysql-4.0.6-12 looks for MySQL's socket in /tmp/mysql.sock, but Red Hat
7.2's mysql RPMs place this socket in /var/lib/mysql.sock. This can make
mysql_connect fail in this version where it worked previously.

Version-Release number of selected component (if applicable):

How reproducible:

Steps to Reproduce:
1. Write PHP code of the form:
    $db = mysql_connect($mysqlhost, $mysqluser, $mysqlpasswd)
        or die("Could not connect to MySQL.");
    print "We connected.";
2. Place PHP code in file on web server with this RPM installed, and visit the
page with the PHP code.

Actual Results:  Error message:

Warning: Can't connect to local MySQL server through socket '/tmp/mysql.sock'
(2) in whatever.php on line 7
Could not connect to MySQL.

Expected Results:  Database connection should be made and PHP script should
continue execution. In the above example "We connected." should appear, not
"Could not connect to MySQL."

Additional info:

This can be worked around by editing /etc/php.ini and setting 

mysql.default_socket    =       /var/lib/mysql/mysql.sock

then restarting httpd.

Comment 1 Seth Vidal 2002-03-01 06:41:26 UTC
ditto. I can recreate this case.

same fix - but it should follow what mysql_config outputs for the socket location.

Comment 2 Seth Vidal 2002-03-01 06:51:56 UTC
Additionally - the configure script for php has:
if test "$PHP_MYSQL" = "yes"; then
  echo $ac_n "checking for MySQL UNIX socket""... $ac_c" 1>&6
echo "configure:29800: checking for MySQL UNIX socket" >&5
  for i in  \
      /var/run/mysqld/mysqld.sock \
      /var/tmp/mysql.sock \
      /var/lib/mysql/mysql.sock \
      /var/mysql/mysql.sock \
      ; do
    if test -r $i; then

it should really just call mysql_config --socket and use that value as the sock

then you can build it based on the lib NOT the current config on the build system

Comment 3 Peter Bowen 2002-03-02 23:28:02 UTC
*** Bug 60623 has been marked as a duplicate of this bug. ***

Comment 4 Seth Vidal 2002-03-03 17:48:25 UTC
Not to be a nag, but any movement on new pkgs to fix this? I'm waiting to roll
out these patches and I'd rather not have to hand edit each php.ini for all
those systems if possible. At the same time I don't like having this php bug
sitting open either :)


Comment 5 Phil Copeland 2002-03-04 18:38:29 UTC
this is whats happening
the mysql.sock named socket only exists when mysqld is RUNNING. The build system
here obviously doesn't have every last daemon running so /var/lib/mysqld.sock
doesn't exist durring the compilation.

The default config.m4, when it doesn't find the socket in any of the proposed
places sets MYSQL_SOCK=/tmp/mysql.sock as a last ditch attempt to make the world
a better place.

Fortunately as you already know, you can OVERRIDE the compiled in default in
locate the line 'mysql.default_socket =' and type in /var/lib/mysql/mysql.sock

That should sort you out, though you should always read through and tweak the
/etc/php.ini file as appropriate for your configuration

I've patched the default php.ini for the next errata (should be a 4.1.2 errata
at some point)


Comment 6 Seth Vidal 2002-03-04 18:51:48 UTC
wouldn't it make more sense to fix the configure script to reference
mysql_config --socket rather than patch the ini to fix it for THIS one case.

that way - in the future if the mysql's named socket location changes in the
mysql package then you don't have to huntdown the modification to php.ini - it
will just FIX the problem.

Then to keep from having to apply that patch forever, it might be worthwhile to
send it upstream to the php folks - its a patch that makes sense no matter what
os someone is building php on.

Comment 7 Phil Copeland 2002-03-04 19:17:38 UTC
*** Bug 60542 has been marked as a duplicate of this bug. ***

Comment 8 Phil Copeland 2002-03-04 19:43:44 UTC
Well thats kinda what I did!
basically if I can find mysql_config, use it else hard code the bugger to
wonder if upstream will consider taking this as it's silly to expect mysql to be
running to get the location of the named socket.


--- php-4.1.2/ext/mysql/config.m4.orig  Mon Mar  4 14:17:09 2002
+++ php-4.1.2/ext/mysql/config.m4       Mon Mar  4 14:30:09 2002
@@ -17,18 +17,23 @@
-  MYSQL_SOCK=/tmp/mysql.sock
-  for i in  \
-      /var/run/mysqld/mysqld.sock \
-      /var/tmp/mysql.sock \
-      /var/lib/mysql/mysql.sock \
-      /var/mysql/mysql.sock \
-      /Private/tmp/mysql.sock \
-      ; do
-    if test -r $i; then
-      MYSQL_SOCK=$i
-    fi
-  done
+  if test -x /usr/bin/mysql_config; then
+    MYSQL_SOCK=`/usr/bin/mysql_config --socket`
+  else
+    MYSQL_SOCK=/var/lib/mysql/mysql.sock
+    for i in  \
+        /var/run/mysqld/mysqld.sock \
+        /var/tmp/mysql.sock \
+        /var/lib/mysql/mysql.sock \
+        /var/mysql/mysql.sock \
+        /Private/tmp/mysql.sock \
+        ; do
+      if test -r $i; then
+        MYSQL_SOCK=$i
+      fi
+    done
+  fi

Comment 9 Seth Vidal 2002-03-04 21:03:13 UTC
oh cool. The way you described it - I thought you said you had patched the
default php.ini file -not the configure for building

Comment 10 Phil Copeland 2002-03-04 21:10:11 UTC
Well,.. I'm kinda going to have to patch the php.ini file anyway for the .dll
mess 8/ otherwise rpm -V will always get upset

Never a dull moment...

Comment 11 Phil Copeland 2002-03-05 18:49:24 UTC
*** Bug 60731 has been marked as a duplicate of this bug. ***

Comment 12 Seth Vidal 2002-03-05 18:56:51 UTC
regarding that 4.1.2 errata - has it made it into QA yet? is it imminent or

Comment 13 Phil Copeland 2002-03-05 19:30:13 UTC
I'm hoping that if teh rawhide version stands up ok I'll have it in with QA next

Comment 14 Phil Copeland 2002-03-06 07:03:19 UTC
*** Bug 60739 has been marked as a duplicate of this bug. ***

Comment 15 Phil Copeland 2002-03-06 07:41:02 UTC
*** Bug 60749 has been marked as a duplicate of this bug. ***

Comment 16 Phil Copeland 2002-03-06 17:46:56 UTC
*** Bug 60774 has been marked as a duplicate of this bug. ***

Comment 17 Phil Copeland 2002-03-07 21:24:16 UTC
*** Bug 60840 has been marked as a duplicate of this bug. ***

Comment 18 Phil Copeland 2002-03-22 07:29:22 UTC
*** Bug 61619 has been marked as a duplicate of this bug. ***

Comment 19 Phil Copeland 2002-03-27 19:21:15 UTC
*** Bug 61401 has been marked as a duplicate of this bug. ***

Comment 20 Oliver Schulze L. 2002-03-29 05:18:09 UTC
Does php-4.0.6-15 from RH 7.2 updates solve the problem?

Note You need to log in before you can comment on or make changes to this bug.