Am 11.08.2006 um 17:54 schrieb William Squires:

I'm trying to use PHP to connect to a MySQL database (to which I have already set up). Individually each works (PHP - ver 4.4.1 and MySQL ver 5.0.24 standard); I can write PHP into an html page, and I can connect to my MySQL database through the 'mysql' command from Terminal.app, but I can't get a connection from PHP to the MySQL database

Warning: mysql_connect(): Can't connect to local MySQL server through socket '/var/mysql/mysql.sock' (2) in /Users/wsquires/Sites/ newtest.php on line 12 Could not connect: Can't connect to local MySQL server through socket '/var/mysql/mysql.sock' (2)

Using terminal, I check /Var and there isn't even a 'mysql' directory there, much less a file 'mysql.sock'. Thinking maybe the lack of the directory was the problem, I created one there with 'sudo mkdir mysql' then did a 'sudo chown root:wheel mysql' so it would look like the other directories under /var, but to no avail.

In your /etc/php.cfg file, you can define if PHP should use sockets - instead of TCP/IP -
for __localhost__ connections. Note, that localhost is key here.

If you use 127.0.0.1 in your PHP MySQL-connect call, PHP won't use sockets anyway.

In case you wan't MySQL to accept socket calls, ensure that the user of the MySQL process has rights to write into /var/mysql. Furthermore, enable sockets in / etc/my.cfg and set
an appropriate file for the socket.

This needs to be the same socket, which you need to define in your / etc/php.cfg



_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Reply via email to