For Programmers: Free Programming Magazines  


Home > Archive > PHP DB > March 2007 > help with mysql connect error









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author help with mysql connect error
Tim McGeary

2007-02-08, 6:58 pm

I am new to this list today, so if I should be sending this to another
specific PHP list, please let me know.

I am getting the following error via the PHP web page I am building:

> Warning: mysql_connect(): Can't connect to local MySQL server through
> socket '/var/lib/mysql/mysql.sock' (13) in
> /var/www/html/software/index.php on line 18 Can't connect to local
> MySQL server through socket '/var/lib/mysql/mysql.sock' (13)


Here are lines 12-19 in my index.php file in which I am trying to
establish a mysql connection:

> <?php
> $hostname = "localhost";
> $username = "softread";
> $password = "XXXXXXX"; // XXXX'd out for list only
> $dbname = "software";
>
> mysql_connect($hostname, $username, $password) or die(mysql_error());
> mysql_select_db($dbname) or die(mysql_error());


I am running this on a RH ES 3.0, using PHP 4.3.2, and MySQL 5.0.27. I
CAN connect to MySQL via the following commands:

> # mysql -usoftread -p software

AND
> # mysql --socket=/var/lib/mysql/mysql.sock -usoftread -pXXXXXX software


I can also connect to the MySQL database via the web using webmin. And
here are the php.ini configurations for MySQL:

> mysql.allow_persistent = On
> mysql.max_persistent = -1
> mysql.max_links = -1
> mysql.default_port = 3306
> mysql.default_socket =
> mysql.default_host = localhost
> mysql.default_user =
> mysql.default_password =
> mysql.connect_timeout = -1
> mysql.trace_mode = Off


From googling the error message and reading the suggestions of others,
I think I've covered all of my bases. What else do I need to look at
that could be causing this problem? I've had a person who is used to
configuring servers to use PHP and MySQL look at this and he also thinks
I've got it setup correctly. Help!

Thanks,
Tim


Haydar TUNA

2007-03-25, 6:57 pm

Hello,
Firstly download the PHP 5.X source tar.gz package and then install
the PHP 5.X --with-mysql=DIR parameter (DIR is the mysql 5 installation
directory). If you try to use this method, your problem will be fixed. I
think you installed the mysql 5 and PHP 4 together with --with-mysql PHP
installation parameters. You didn't use --with-mysql=DIR parameter. For this
reason, PHP 4 support mysql 3.X and mysql 4.X connection.:)

"Tim McGeary" <tmm8@Lehigh.EDU>, haber iletisinde sunlari
yazdi:45CB4F85.9070600@lehigh.edu...
>I am new to this list today, so if I should be sending this to another
> specific PHP list, please let me know.
>
> I am getting the following error via the PHP web page I am building:
>
>
> Here are lines 12-19 in my index.php file in which I am trying to
> establish a mysql connection:
>
>
> I am running this on a RH ES 3.0, using PHP 4.3.2, and MySQL 5.0.27. I
> CAN connect to MySQL via the following commands:
>
> AND
>
> I can also connect to the MySQL database via the web using webmin. And
> here are the php.ini configurations for MySQL:
>
>
> From googling the error message and reading the suggestions of others,
> I think I've covered all of my bases. What else do I need to look at
> that could be causing this problem? I've had a person who is used to
> configuring servers to use PHP and MySQL look at this and he also thinks
> I've got it setup correctly. Help!
>
> Thanks,
> Tim
>
>

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com