Bug 60515 - php-mysql-4.0.6-12 looks for mysql.sock in wrong location
php-mysql-4.0.6-12 looks for mysql.sock in wrong location
Status: CLOSED ERRATA
Product: Red Hat Linux
Classification: Retired
Component: php (Show other bugs)
7.2
i386 Linux
medium Severity low
: ---
: ---
Assigned To: Phil Copeland
David Lawrence
:
: 60542 60623 60731 60739 60749 60774 60840 61401 61619 (view as bug list)
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2002-02-28 16:09 EST by Mark Cornick
Modified: 2014-01-21 17:48 EST (History)
6 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2002-03-03 12:48:30 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:


Attachments (Terms of Use)

  None (edit)
Description Mark Cornick 2002-02-28 16:09:14 EST
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:
Always

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 01:41:26 EST
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 01:51:56 EST
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
  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 \
      ; do
    if test -r $i; then
 	MYSQL_SOCK=$i
    fi
  done


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

then you can build it based on the lib NOT the current config on the build system
Comment 3 Peter Bowen 2002-03-02 18:28:02 EST
*** Bug 60623 has been marked as a duplicate of this bug. ***
Comment 4 Seth Vidal 2002-03-03 12:48:25 EST
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 :)

Thanks


Comment 5 Phil Copeland 2002-03-04 13:38:29 EST
*sigh*
ok
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
/etc/php.ini
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)

Phil
=--=
Comment 6 Seth Vidal 2002-03-04 13:51:48 EST
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 14:17:38 EST
*** Bug 60542 has been marked as a duplicate of this bug. ***
Comment 8 Phil Copeland 2002-03-04 14:43:44 EST
Well thats kinda what I did!
basically if I can find mysql_config, use it else hard code the bugger to
/var/lib/mysql
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.

Phil
=--=

--- 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 @@
 
 AC_DEFUN(PHP_MYSQL_SOCK,[
   AC_MSG_CHECKING(for MySQL UNIX socket)
-  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
+
   AC_DEFINE_UNQUOTED(MYSQL_UNIX_ADDR, "$MYSQL_SOCK", [ ])
   AC_MSG_RESULT($MYSQL_SOCK)
 ])
Comment 9 Seth Vidal 2002-03-04 16:03:13 EST
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 16:10:11 EST
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 13:49:24 EST
*** Bug 60731 has been marked as a duplicate of this bug. ***
Comment 12 Seth Vidal 2002-03-05 13:56:51 EST
regarding that 4.1.2 errata - has it made it into QA yet? is it imminent or
eventual?

Comment 13 Phil Copeland 2002-03-05 14:30:13 EST
I'm hoping that if teh rawhide version stands up ok I'll have it in with QA next
week.
Comment 14 Phil Copeland 2002-03-06 02:03:19 EST
*** Bug 60739 has been marked as a duplicate of this bug. ***
Comment 15 Phil Copeland 2002-03-06 02:41:02 EST
*** Bug 60749 has been marked as a duplicate of this bug. ***
Comment 16 Phil Copeland 2002-03-06 12:46:56 EST
*** Bug 60774 has been marked as a duplicate of this bug. ***
Comment 17 Phil Copeland 2002-03-07 16:24:16 EST
*** Bug 60840 has been marked as a duplicate of this bug. ***
Comment 18 Phil Copeland 2002-03-22 02:29:22 EST
*** Bug 61619 has been marked as a duplicate of this bug. ***
Comment 19 Phil Copeland 2002-03-27 14:21:15 EST
*** Bug 61401 has been marked as a duplicate of this bug. ***
Comment 20 Oliver Schulze L. 2002-03-29 00:18:09 EST
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.