Database connection?

Problems with the Linux version of XAMPP, questions, comments, and anything related.

Database connection?

Postby arun » 10. March 2005 06:16

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
arun
 
Posts: 8
Joined: 08. March 2005 13:09

Postby Kristian Marcroft » 10. March 2005 09:23

Hi,

try looking at the source of the Script?

So long
KriS
User avatar
Kristian Marcroft
AF Moderator
 
Posts: 2962
Joined: 03. January 2003 12:08
Location: Diedorf

Postby argie01 » 10. March 2005 10:27

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.
argie01
 
Posts: 29
Joined: 19. July 2004 19:17

Postby Kristian Marcroft » 10. March 2005 10:39

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
User avatar
Kristian Marcroft
AF Moderator
 
Posts: 2962
Joined: 03. January 2003 12:08
Location: Diedorf

Postby arun » 10. March 2005 10:52

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??
arun
 
Posts: 8
Joined: 08. March 2005 13:09

Postby arun » 10. March 2005 10:57

But there is no folder called " mysql" in '/var/lib/"
arun
 
Posts: 8
Joined: 08. March 2005 13:09

Postby argie01 » 10. March 2005 10:58

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 !
argie01
 
Posts: 29
Joined: 19. July 2004 19:17

Postby arun » 10. March 2005 12:04

still the problem not solved..
arun
 
Posts: 8
Joined: 08. March 2005 13:09

Postby ricen13 » 11. March 2005 05:59

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.
User avatar
ricen13
 
Posts: 1
Joined: 11. March 2005 05:55

Postby arun » 11. March 2005 10:53

your suggession is so useful

Thank you
arun
 
Posts: 8
Joined: 08. March 2005 13:09


Return to XAMPP for Linux

Who is online

Users browsing this forum: No registered users and 32 guests