Page 1 of 1

Database connection?

PostPosted: 10. March 2005 06:16
by arun
i have problem to connect to database..
this is the error i got

Server Error. Please contact Customer Support for help. Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)

But mysql.sock is present in /opt/lampp/var/mysql/mysql.sock


While i run login.pl file from shell by using "perl -wc login.pl" i got the following error

DBI connect('almeorg_almeda:localhost',' ',...) failed: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) at /usr/almeorg/public_html/PerlModule/RY_DB_String.pm line 16
Content-type: text/html

login.pl syntax OK
<font size="4" face="Verdana">Server Error. Please contact Customer Support for help. Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)

How do solve this..

Arun

PostPosted: 10. March 2005 09:23
by Kristian Marcroft
Hi,

try looking at the source of the Script?

So long
KriS

PostPosted: 10. March 2005 10:27
by argie01
The problem with is line

Server Error. Please contact Customer Support for help. Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)


is because your dir /mysql (inside /lampp/var/) hasn't the right user.group permisions.
You have to chown it, and restart your server.

PostPosted: 10. March 2005 10:39
by Kristian Marcroft
Hi,

no thats wrong!!!
It's not even looking in /opt/lampp/var/mysql...

It's looking in the wrong place for the mysql.sock
And this is as it looks hardcoded in the perl Script!

So all that has to be done is change the code so that the Path to mysql.sock is set to /opt/lampp/var/mysql

There is no error anywhere telling you that the rights of the dir is wrong.
If that was the case it would tell you so!

So long
KriS

PostPosted: 10. March 2005 10:52
by arun
Hi

Thanks for reply..

The folder permission is being 755 (mysql)(inside /lampp/var/)
But it won't works..

The following is my sample code for database connection

#!/use/bin/perl -w

use DBI;
use CGI;
login();
sub login
{
my $connection=DBI->connect("DBI:mysql:test;host=localhost:port=3306", "","");
if ( not $connection )
{
print "Unable to connect";
}

}

Now it says "Internal Server Error"
following error in error_log file
"Premature end of script headers:testconnect.pl"

What i need to do??

PostPosted: 10. March 2005 10:57
by arun
But there is no folder called " mysql" in '/var/lib/"

PostPosted: 10. March 2005 10:58
by argie01
Well, I don't know in your case, but in my case the /mysql directory is assigned to this user/group:

nobody root

I did this:

chown -R nobody.root /mysql


and the problem went out !

PostPosted: 10. March 2005 12:04
by arun
still the problem not solved..

PostPosted: 11. March 2005 05:59
by ricen13
try making a mysql dir inside /var/lib like this: /var/lib/mysql

then inside it, make a symbolic link to the mysql.sock path like this:

ln -s /opt/lampp/var/mysql/mysql.sock ./

then try to connect.

PostPosted: 11. March 2005 10:53
by arun
your suggession is so useful

Thank you