Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > not able to connect to mysql

Reply
Thread Tools

not able to connect to mysql

 
 
HP
Guest
Posts: n/a
 
      01-06-2006
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?

 
Reply With Quote
 
 
 
 
Brian Wakem
Guest
Posts: n/a
 
      01-06-2006
HP wrote:
> 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.



--
Brian Wakem
Email: http://homepage.ntlworld.com/b.wakem/myemail.png
 
Reply With Quote
 
 
 
 
HP
Guest
Posts: n/a
 
      01-06-2006
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

 
Reply With Quote
 
HP
Guest
Posts: n/a
 
      01-06-2006
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?

 
Reply With Quote
 
Brian Wakem
Guest
Posts: n/a
 
      01-06-2006
HP wrote:

> 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?



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.


--
Brian Wakem
Email: http://homepage.ntlworld.com/b.wakem/myemail.png
 
Reply With Quote
 
HP
Guest
Posts: n/a
 
      01-06-2006
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

 
Reply With Quote
 
HP
Guest
Posts: n/a
 
      01-06-2006
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

 
Reply With Quote
 
HP
Guest
Posts: n/a
 
      01-06-2006
>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

 
Reply With Quote
 
HP
Guest
Posts: n/a
 
      01-06-2006
>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.

 
Reply With Quote
 
Brian Wakem
Guest
Posts: n/a
 
      01-07-2006
HP wrote:

>>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.



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.


--
Brian Wakem
Email: http://homepage.ntlworld.com/b.wakem/myemail.png
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Not able to display color in excel not able to display color in excel using xml sed_y XML 0 02-15-2012 09:46 PM
Aliant TV - Trying to connect a wireless router, not able to connect to Internet rich irving Computer Support 5 01-11-2006 06:30 PM
Not able to install 'Msql-Mysql-modules' Francesco Moi Perl Misc 0 07-27-2005 04:28 PM
Not able to Connect to Internet while using wireless card =?Utf-8?B?c3JlZQ==?= Wireless Networking 0 11-09-2004 06:07 PM
Seen this message? Can't connect to local MySQL server through socket '/tmp/mysql.sock' Allen Marshall Perl Misc 1 01-24-2004 10:55 PM



Advertisments