Greetings,
sc***********@googlemail.com.
In reply to Your message dated Tuesday, April 8, 2008, 22:23:20,
The local mysql server is running on my Macbook. I can access it
through the console client:
$ mysql -u root
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.0.45 MySQL Community Server (GPL)
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql>>
But when I launch a PHP script that tries to connect to it, I get an
error:
$link = mysql_connect("localhost", "root", "");
First: Don't use 'root' in any other case than maintenance purposes.
Warning: mysql_connect(): Can't connect to local MySQL server through
socket '/var/mysql/mysql.sock' (2)
Any ideas what's going on?
RTFM, seriously.
http://www.php.net/manual/en/function.mysql-connect.php
Note: Whenever you specify "localhost" or "localhost:port" as server, the
MySQL client library will override this and try to connect to a local socket
(named pipe on Windows). If you want to use TCP/IP, use "127.0.0.1" instead of
"localhost". If the MySQL client library tries to connect to the wrong local
socket, you should set the correct path as Runtime Configuration in your PHP
configuration and leave the server field blank.
From my experience, this may cause some unexpected things, at least in
Windows.
Try
$link = mysql_connect("127.0.0.1", "username", "password");
--
Sincerely Yours, AnrDaemon <an*******@freemail.ru>