not able to connect to mysql

H

HP

Hi All

this is my code:

$db = DBI->connect($dbpath, $dbuser , $dbpass) || die "cannot connect
to database".$DBI::errstr;

i am trying to connect to mysql database.when i am running as perl
-cgi script on command line its working fine.
but when i am running it through browser its giving me this error .

Can't connect to local MySQL server through socket
'/var/lib/mysql/mysql.sock'

do anyone know the reason?
 
B

Brian Wakem

HP said:
Hi All

this is my code:

$db = DBI->connect($dbpath, $dbuser , $dbpass) || die "cannot connect
to database".$DBI::errstr;

i am trying to connect to mysql database.when i am running as perl
-cgi script on command line its working fine.
but when i am running it through browser its giving me this error .

Can't connect to local MySQL server through socket
'/var/lib/mysql/mysql.sock'

do anyone know the reason?



Probably a permissions issue. You missed the all important number off
the end of that error message.
 
H

HP

the whole error message is-


Can't connect to local MySQL server through socket
'/var/lib/mysql/mysql.sock' (13)
Probably a permissions issue
i am writing cgi script as a root user and giving the file
chmod 755.
what can be the reason
 
H

HP

the whole error string is-

Can't connect to local MySQL server through socket
'/var/lib/mysql/mysql.sock' (13)
Probably a permissions issue

i am creating the file with root permission, changing the mode of file
chmod 755

do you think anything wrong here?
 
B

Brian Wakem

HP said:
the whole error string is-

Can't connect to local MySQL server through socket
'/var/lib/mysql/mysql.sock' (13)


i am creating the file with root permission, changing the mode of file
chmod 755

do you think anything wrong here?


Yes mysql needs to own the file and have permission to write to it. Also
you need to check that mysql is actually running and that the path to the
sock file is correct in the first place.
 
H

HP

i have chenged the permission to write but the problem still occuring.
mysql is running fine.i am able to run this scriot from command line.
even path of mysql.sock is right

help me out please
 
H

HP

i have changed the permission to write but the problem still occuring.
mysql is running fine.i am able to run this scriot from command line.
even path of mysql.sock is right

help me out please
 
H

HP

Yes mysql needs to own the file and have permission to write to it

i have changed the permission to write but problem is still thete.
you need to check that mysql is actually running

mysql is running fine. my script is running fine from the command line.
the path to the sock file is correct in the first place.
place of mysql.sock is right.

help me out please
 
H

HP

mysql needs to own the file and have permission to write to it

i have changed the permission to write the problem is still there
you need to check that mysql is actually running

mysql is running fine,since i am able to run this script fron=m the
command line mode
the path to thesock file is correct in the first place.
the path of sockfile is correct.
 
B

Brian Wakem

HP said:
i have changed the permission to write the problem is still there

mysql is running fine,since i am able to run this script fron=m the
command line mode

the path of sockfile is correct.


It must be a permissions problem then.

First do this:

mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 105 to server version: 4.1.11

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> status
--------------
mysql Ver 14.7 Distrib 4.1.11, for mandrake-linux-gnu (i586)

Connection id: 105
Current database:
Current user: root@localhost
SSL: Not in use
Current pager: stdout
Using outfile: ''
Using delimiter: ;
Server version: 4.1.11
Protocol version: 10
Connection: Localhost via UNIX socket
Server characterset: latin1
Db characterset: latin1
Client characterset: latin1
Conn. characterset: latin1
UNIX socket: /var/lib/mysql/mysql.sock

And make sure the UNIX socket line definitely says /var/lib/mysql/mysql.sock
and not /tmp/mysql.sock

Now chown and chgrp the socket file to the user mysql runs under (probably
mysql). Then, and this is the bit that can stump some people, the mysql
user needs permission to enter the directory the socket file is in, so
chown and chgrp /var/lib/mysql.

Now this is nothing to do with perl so you should post any further questions
to a mysql group.
 
H

HP

Hi All

i wana give you more information regarding my database.
mysql database is managed by phpmyadmin.
and my database is created by phpmyadmin.
while as a user i have all the priviledge
do you think it can be problem from connecting to database through
perl cgi script.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top