Re: php cli and mysql

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





Chris wrote:
Tom Ray [Lists] wrote:


Roman Neuhauser wrote:
# cajbecu@xxxxxxxxx / 2006-11-14 20:17:16 +0200:
On 11/14/06, James Tu <jtu@xxxxxxxxxxxxx> wrote:
I'm running a php script from the command line (I'm on OS X) and I'm
getting ...

Warning: mysql_connect(): Can't connect to local MySQL server through
socket '/var/mysql/mysql.sock' (2)
touch /var/mysql/mysql.sock
chmod 777 /var/mysql/mysql.sock

    How could that possibly help?
Because if the mysql.sock file is missing the mysql server won't start. If the mysql server isn't running the PHP script won't work. So I think it helps a lot.

Actually the opposite - it becomes a lot harder to debug/diagnose. PHP uses the socket file to talk to mysql if you connect to 'localhost' rather than using a tcp/ip connection. If the socket file is invalid (as this would be), then mysql_connect fails, mysql_query fails and so on.

The problem as it turns out was that php was looking in the wrong place, if this file was there and empty, then you'd get completely different errors which would make it harder to find the original problem.

Well that's odd because on all my servers the mysql.sock is empty and if it's missing mysql tells me it can't find the sock file when it starts up. This wasn't an actual PHP problem, even trying to connect to the mysql server via /usr/local/mysql/bin/mysql -u user -p database would have produced that error.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux