[EMAIL PROTECTED] wrote:
Remember guys, I went through this on the phpmyadmin list before
turning here.
That doesn't help us much, as we haven't seen that conversation.
I was told to run the command 'mysqladmin variables' to find out where
the socket was; I did that successfully and it showed up at
/var/mysql/mysql.sock.
And viola, now with mysqld running, it does show up there, at /var/
mysql/mysql.sock. When I shutdown mysqld it is gone, from /var/mysql.
Earlier, you wrote:
> What I do get is why running 'mysqladmin -variables' reports the
> location of mysql.sock and there seems to be no mysql.sock anywhere
> on this machine! Not in /tmp not /var/mysql (where it says it is).
At that point, then, mysqld was not running, so connecting would have
been impossible. Now mysqld is running, so connecting *should* be
possible. Indeed, you report success connecting via the mysql client.
Unfortunately, this puts us back at square one. To diagnose the
problem, we need the php error message when the connect fails. I
suspect the message you showed before was from when mysql wasn't
running. I could be wrong, but with just bits and pieces, rather than a
clear narrative, it's hard to know what's going on.
(Btw, once in a recent post of mine, Philip referred to my leaving out
the leading / at 'var', that was simply a typo and it was in the script
post.)
So, running 'mysql variables' is giving me the socket path and I'm
still lost as to what's going why I cannot connect with a simple php
script.
php can tell you what's wrong, if you let it. The code you showed us
doesn't really check for errors. Try changing it to this:
<?php
$server = "localhost:/var/mysql/mysql.sock";
$user="mysuperuser";
$password="mypassword";
$db = "mysql";
mysql_connect($server, $user, $password)
or die('Could not connect: ' . mysql_error());
mysql_select_db($db) or die('Could not select db: ' . mysql_error());
?>
Make sure mysqld is running (/var/mysql/mysql.sock exists, can connect
with mysql client) then try this script. If it fails to connect, post
the error message.
Help?! I'll look for the mysql error log.
The default location of the log is the file hostname.err in mysql's data
directory (where hostname is the name of your machine). I don't think
the mysql log will help though, as the error appears to be on the php side.
Gil
Meanwhile, I should point out that while it is true that Mac OS X Server
10.4 ships with mysql and php, for some reason they've been shipped with
incompatible defaults, as you are seeing. Have you read what Apple has
to say on the matter
<http://docs.info.apple.com/article.html?artnum=301457>? If you
haven't, then you probably haven't changed permissions on /var/mysql so
that www, the apache user, can access the socket. They suggest
sudo chmod 775 /var/mysql
but
sudo chmod 711 /var/mysql
should be sufficient (and safer).
They also suggest editing/creating /etc/php.ini to make the correct
location of mysql's socket file the default for php, though this
shouldn't be necessary, as you are specifying the location in your
connection string.
If you're still having problems, inclde the output of
cd /var/mysql && ls -l
in your next post.
Michael
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]