MySQL server running, PHP can"t connect
MySQL server running, PHP can"t connect
am 08.04.2008 20:23:20 von scorpionbilli
Hi,
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", "");
Warning: mysql_connect(): Can't connect to local MySQL server through
socket '/var/mysql/mysql.sock' (2)
Any ideas what's going on?
Re: MySQL server running, PHP can"t connect
am 08.04.2008 21:37:38 von Jerry Stuckle
scorpionbilli@googlemail.com wrote:
> Hi,
>
> 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", "");
>
> Warning: mysql_connect(): Can't connect to local MySQL server through
> socket '/var/mysql/mysql.sock' (2)
>
> Any ideas what's going on?
>
Does /var/mysql/mysql.sock exist? What are its permissions?
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Re: MySQL server running, PHP can"t connect
am 08.04.2008 21:37:38 von Jerry Stuckle
scorpionbilli@googlemail.com wrote:
> Hi,
>
> 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", "");
>
> Warning: mysql_connect(): Can't connect to local MySQL server through
> socket '/var/mysql/mysql.sock' (2)
>
> Any ideas what's going on?
>
Does /var/mysql/mysql.sock exist? What are its permissions?
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Re: MySQL server running, PHP can"t connect
am 08.04.2008 21:47:01 von scorpionbilli
On Apr 8, 9:37 pm, Jerry Stuckle wrote:
> scorpionbi...@googlemail.com wrote:
> > Hi,
>
> > 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", "");
>
> > Warning: mysql_connect(): Can't connect to local MySQL server through
> > socket '/var/mysql/mysql.sock' (2)
>
> > Any ideas what's going on?
>
> Does /var/mysql/mysql.sock exist? What are its permissions?
>
> --
> ==================
> Remove the "x" from my email address
> Jerry Stuckle
> JDS Computer Training Corp.
> jstuck...@attglobal.net
> ==================
No, /var/mysql does't exist. locate mysql.sock shows one at /private/
tmp/mysql.sock .
Should I configure PHP to use that, or configure MySQL to place the
socket somewhere else?
Re: MySQL server running, PHP can"t connect
am 08.04.2008 21:47:01 von scorpionbilli
On Apr 8, 9:37 pm, Jerry Stuckle wrote:
> scorpionbi...@googlemail.com wrote:
> > Hi,
>
> > 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", "");
>
> > Warning: mysql_connect(): Can't connect to local MySQL server through
> > socket '/var/mysql/mysql.sock' (2)
>
> > Any ideas what's going on?
>
> Does /var/mysql/mysql.sock exist? What are its permissions?
>
> --
> ==================
> Remove the "x" from my email address
> Jerry Stuckle
> JDS Computer Training Corp.
> jstuck...@attglobal.net
> ==================
No, /var/mysql does't exist. locate mysql.sock shows one at /private/
tmp/mysql.sock .
Should I configure PHP to use that, or configure MySQL to place the
socket somewhere else?
Re: MySQL server running, PHP can"t connect
am 08.04.2008 21:54:06 von scorpionbilli
On Apr 8, 9:47 pm, scorpionbi...@googlemail.com wrote:
> On Apr 8, 9:37 pm, Jerry Stuckle wrote:
>
>
>
> > scorpionbi...@googlemail.com wrote:
> > > Hi,
>
> > > 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", "");
>
> > > Warning: mysql_connect(): Can't connect to local MySQL server through
> > > socket '/var/mysql/mysql.sock' (2)
>
> > > Any ideas what's going on?
>
> > Does /var/mysql/mysql.sock exist? What are its permissions?
>
> > --
> > ==================
> > Remove the "x" from my email address
> > Jerry Stuckle
> > JDS Computer Training Corp.
> > jstuck...@attglobal.net
> > ==================
>
> No, /var/mysql does't exist. locate mysql.sock shows one at /private/
> tmp/mysql.sock .
>
> Should I configure PHP to use that, or configure MySQL to place the
> socket somewhere else?
I forgot to add: /var, /tmp and /etc are all linked to /private
subdirectories, so the mysql.sock would be reachable at /tmp/
mysql.sock .
Mh. I'll try symlinking /var/mysql/mysql.sock to that.
Re: MySQL server running, PHP can"t connect
am 08.04.2008 21:54:06 von scorpionbilli
On Apr 8, 9:47 pm, scorpionbi...@googlemail.com wrote:
> On Apr 8, 9:37 pm, Jerry Stuckle wrote:
>
>
>
> > scorpionbi...@googlemail.com wrote:
> > > Hi,
>
> > > 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", "");
>
> > > Warning: mysql_connect(): Can't connect to local MySQL server through
> > > socket '/var/mysql/mysql.sock' (2)
>
> > > Any ideas what's going on?
>
> > Does /var/mysql/mysql.sock exist? What are its permissions?
>
> > --
> > ==================
> > Remove the "x" from my email address
> > Jerry Stuckle
> > JDS Computer Training Corp.
> > jstuck...@attglobal.net
> > ==================
>
> No, /var/mysql does't exist. locate mysql.sock shows one at /private/
> tmp/mysql.sock .
>
> Should I configure PHP to use that, or configure MySQL to place the
> socket somewhere else?
I forgot to add: /var, /tmp and /etc are all linked to /private
subdirectories, so the mysql.sock would be reachable at /tmp/
mysql.sock .
Mh. I'll try symlinking /var/mysql/mysql.sock to that.
Re: MySQL server running, PHP can"t connect
am 08.04.2008 22:21:07 von scorpionbilli
On Apr 8, 9:54 pm, scorpionbi...@googlemail.com wrote:
> On Apr 8, 9:47 pm, scorpionbi...@googlemail.com wrote:
>
>
>
> > On Apr 8, 9:37 pm, Jerry Stuckle wrote:
>
> > > scorpionbi...@googlemail.com wrote:
> > > > Hi,
>
> > > > 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", "");
>
> > > > Warning: mysql_connect(): Can't connect to local MySQL server through
> > > > socket '/var/mysql/mysql.sock' (2)
>
> > > > Any ideas what's going on?
>
> > > Does /var/mysql/mysql.sock exist? What are its permissions?
>
> > > --
> > > ==================
> > > Remove the "x" from my email address
> > > Jerry Stuckle
> > > JDS Computer Training Corp.
> > > jstuck...@attglobal.net
> > > ==================
>
> > No, /var/mysql does't exist. locate mysql.sock shows one at /private/
> > tmp/mysql.sock .
>
> > Should I configure PHP to use that, or configure MySQL to place the
> > socket somewhere else?
>
> I forgot to add: /var, /tmp and /etc are all linked to /private
> subdirectories, so the mysql.sock would be reachable at /tmp/
> mysql.sock .
>
> Mh. I'll try symlinking /var/mysql/mysql.sock to that.
Don't have access to root right now. Is there any other way of doing
this?
Re: MySQL server running, PHP can"t connect
am 08.04.2008 22:21:07 von scorpionbilli
On Apr 8, 9:54 pm, scorpionbi...@googlemail.com wrote:
> On Apr 8, 9:47 pm, scorpionbi...@googlemail.com wrote:
>
>
>
> > On Apr 8, 9:37 pm, Jerry Stuckle wrote:
>
> > > scorpionbi...@googlemail.com wrote:
> > > > Hi,
>
> > > > 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", "");
>
> > > > Warning: mysql_connect(): Can't connect to local MySQL server through
> > > > socket '/var/mysql/mysql.sock' (2)
>
> > > > Any ideas what's going on?
>
> > > Does /var/mysql/mysql.sock exist? What are its permissions?
>
> > > --
> > > ==================
> > > Remove the "x" from my email address
> > > Jerry Stuckle
> > > JDS Computer Training Corp.
> > > jstuck...@attglobal.net
> > > ==================
>
> > No, /var/mysql does't exist. locate mysql.sock shows one at /private/
> > tmp/mysql.sock .
>
> > Should I configure PHP to use that, or configure MySQL to place the
> > socket somewhere else?
>
> I forgot to add: /var, /tmp and /etc are all linked to /private
> subdirectories, so the mysql.sock would be reachable at /tmp/
> mysql.sock .
>
> Mh. I'll try symlinking /var/mysql/mysql.sock to that.
Don't have access to root right now. Is there any other way of doing
this?
Re: MySQL server running, PHP can"t connect
am 08.04.2008 22:40:29 von gordonb.tsooi
>The local mysql server is running on my Macbook. I can access it
>through the console client:
When you connect using a socket, the server and the client must
agree on the location of the socket.
>$ 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 -h localhost -u root
>mysql>
At this point, type \s [ENTER] at the prompt. It will tell you a
number of things. Look for the line that tells you about the path
name to the socket (usually ends in 'mysql.sock'), e.g.:
mysql>\s
....
UNIX Socket: /tmp/mysql.sock
....
>But when I launch a PHP script that tries to connect to it, I get an
>error:
>
>$link = mysql_connect("localhost", "root", "");
>
>Warning: mysql_connect(): Can't connect to local MySQL server through
>socket '/var/mysql/mysql.sock' (2)
perror 2 on my system is "no such file or directory".
>
>Any ideas what's going on?
PHP doesn't know the correct path for the socket.
In php.ini, there's a variable setting (likely commented out or
missing in the default distribution file):
mysql.default_socket = "/tmp/mysql.sock"
Now restart your web server.
/tmp/mysql.sock represents the correct socket pathname. Don't
assume it is literally correct just because that's what it is on
my system (FreeBSD). It is important that the server and the client
AGREE, much more important than what the actual path is. Your
server and the command-line client already seem to agree, so use
what they're using.
Re: MySQL server running, PHP can"t connect
am 08.04.2008 22:40:29 von gordonb.tsooi
>The local mysql server is running on my Macbook. I can access it
>through the console client:
When you connect using a socket, the server and the client must
agree on the location of the socket.
>$ 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 -h localhost -u root
>mysql>
At this point, type \s [ENTER] at the prompt. It will tell you a
number of things. Look for the line that tells you about the path
name to the socket (usually ends in 'mysql.sock'), e.g.:
mysql>\s
....
UNIX Socket: /tmp/mysql.sock
....
>But when I launch a PHP script that tries to connect to it, I get an
>error:
>
>$link = mysql_connect("localhost", "root", "");
>
>Warning: mysql_connect(): Can't connect to local MySQL server through
>socket '/var/mysql/mysql.sock' (2)
perror 2 on my system is "no such file or directory".
>
>Any ideas what's going on?
PHP doesn't know the correct path for the socket.
In php.ini, there's a variable setting (likely commented out or
missing in the default distribution file):
mysql.default_socket = "/tmp/mysql.sock"
Now restart your web server.
/tmp/mysql.sock represents the correct socket pathname. Don't
assume it is literally correct just because that's what it is on
my system (FreeBSD). It is important that the server and the client
AGREE, much more important than what the actual path is. Your
server and the command-line client already seem to agree, so use
what they're using.