Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > perl + mysql + apache on windows

Reply
Thread Tools

perl + mysql + apache on windows

 
 
RB
Guest
Posts: n/a
 
      08-12-2003

I am running mySQL 3.23.57 on windows 2000. I configured it to run on named
pipes ( enable-named-pipe ), and the server starts nicely. I have a perl
script which tries to establish a connection to mySQL server:

use DBI;

my $dsn = 'dbi:mysql:mydatabase';

# set the user and password
my $user = 'root';
my $pass = 'xxxxxxxxx';

# now connect and get a database handle
my $dbh = DBI->connect($dsn, $user, $pass);
# or die "Can't connect to the DB: $DBI::errstr\n";
print "done"

When I run this from the command line, the output is a string "done".

When I run the same perl script under cgi-bin using Apache(2.0.47), I can
see the following in the error_log:

[Mon Aug 11 14:42:23 2003] [error] [client w.x.y.z] DBI
connect('mydatabase','root',...) failed: Can't connect to MySQL server on
'localhost' (10061) at E:/Program
Files/ApacheGroup/Apache2/cgi-bin/testdb.pl line 17
[Mon Aug 11 14:42:23 2003] [error] [client w.x.y.z] Can't connect to the DB:
Can't connect to MySQL server on localhost' (10061)

I can of course do this from a shell prompt:

mysql -u root -p mydatabase

mysqld-nt is not listening on port 3306 ( netstat -a shows this )....

What am I missing here? Why do I get the 10061 error ( which seems to be a
Winsock error code - connection refused ).

thanks,
rb


 
Reply With Quote
 
 
 
 
Mothra
Guest
Posts: n/a
 
      08-12-2003
Hello,

"RB" <(E-Mail Removed)> wrote in message
news:Usb_a.175998$(E-Mail Removed) le.rogers.com...
>

[snipped]

> use DBI;
>
> my $dsn = 'dbi:mysql:mydatabase';

[more snippage]

for my $dsn I use
$dsn = "DBI:mysql:database=seating;host=cypci748";
It has the hostname, just a though

Hope this helps

Mothra


 
Reply With Quote
 
 
 
 
Gunnar Hjalmarsson
Guest
Posts: n/a
 
      08-12-2003
RB wrote:
>
> my $dsn = 'dbi:mysql:mydatabase';


<snip>

> What am I missing here? Why do I get the 10061 error ( which seems to be a
> Winsock error code - connection refused ).


Without really knowing the answer to your question, when playing with
MySQL on my local Windows 98 box, I have experienced that I need to
explicitly state 'localhost'. Doing so might be worth a try:

my $dsn = 'dbi:mysql:mydatabase:localhost';

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

 
Reply With Quote
 
RB
Guest
Posts: n/a
 
      08-12-2003
Hi,

I tried what you suggested - changing the dsn to
'dbi:mysql:database=mydatabase:host=localhost' - it had no effect - I still
get the connect error...

thanks,
rb

"Mothra" <(E-Mail Removed)> wrote in message
news:3f37f83e$(E-Mail Removed)...
> Hello,
>
> "RB" <(E-Mail Removed)> wrote in message
> news:Usb_a.175998$(E-Mail Removed) le.rogers.com...
> >

> [snipped]
>
> > use DBI;
> >
> > my $dsn = 'dbi:mysql:mydatabase';

> [more snippage]
>
> for my $dsn I use
> $dsn = "DBI:mysql:database=seating;host=cypci748";
> It has the hostname, just a though
>
> Hope this helps
>
> Mothra
>
>



 
Reply With Quote
 
RB
Guest
Posts: n/a
 
      08-12-2003
I tried what you suggested - i modifed the dsn to be something like:

my $dsn = 'dbi:mysql:database=mydatabase:host=localhost'

it had no effect - I still get the connect error...

thanks,

"Gunnar Hjalmarsson" <(E-Mail Removed)> wrote in message
news:bhbhcb$10b5a5$(E-Mail Removed)-berlin.de...
> RB wrote:
> >
> > my $dsn = 'dbi:mysql:mydatabase';

>
> <snip>
>
> > What am I missing here? Why do I get the 10061 error ( which seems to be

a
> > Winsock error code - connection refused ).

>
> Without really knowing the answer to your question, when playing with
> MySQL on my local Windows 98 box, I have experienced that I need to
> explicitly state 'localhost'. Doing so might be worth a try:
>
> my $dsn = 'dbi:mysql:mydatabase:localhost';
>
> --
> Gunnar Hjalmarsson
> Email: http://www.gunnar.cc/cgi-bin/contact.pl
>



 
Reply With Quote
 
Mothra
Guest
Posts: n/a
 
      08-12-2003
Please do not top post. It anoys the regulars here
[text rearranged]

"RB" <(E-Mail Removed)> wrote in message
news:NVb_a.176187$(E-Mail Removed) ble.rogers.com...
> "Mothra" <(E-Mail Removed)> wrote in message
> news:3f37f83e$(E-Mail Removed)...
> > Hello,
> >
> > "RB" <(E-Mail Removed)> wrote in message
> > news:Usb_a.175998$(E-Mail Removed) le.rogers.com...
> > >

> > [snipped]
> >
> > > use DBI;
> > >
> > > my $dsn = 'dbi:mysql:mydatabase';

> > [more snippage]
> >
> > for my $dsn I use
> > $dsn = "DBI:mysql:database=seating;host=cypci748";
> > It has the hostname, just a though
> >

>"RB" <(E-Mail Removed)> wrote
> Hi,
>
> I tried what you suggested - changing the dsn to
> 'dbi:mysql:database=mydatabase:host=localhost' - it had no effect - I

still
> get the connect error...
>

you might want to try:

telnet localhost 3306
and see if you can get a connection. then troubleshoot from there

Mothra


 
Reply With Quote
 
ctcgag@hotmail.com
Guest
Posts: n/a
 
      08-12-2003
"RB" <(E-Mail Removed)> wrote:
> I am running mySQL 3.23.57 on windows 2000. I configured it to run on
> named pipes ( enable-named-pipe ), and the server starts nicely. I have a
> perl script which tries to establish a connection to mySQL server:
>
> use DBI;
>
> my $dsn = 'dbi:mysql:mydatabase';
>
> # set the user and password
> my $user = 'root';
> my $pass = 'xxxxxxxxx';
>
> # now connect and get a database handle
> my $dbh = DBI->connect($dsn, $user, $pass);
> # or die "Can't connect to the DB: $DBI::errstr\n";
> print "done"
>
> When I run this from the command line, the output is a string "done".
>
> When I run the same perl script under cgi-bin using Apache(2.0.47), I can
> see the following in the error_log:
>
> [Mon Aug 11 14:42:23 2003] [error] [client w.x.y.z] DBI
> connect('mydatabase','root',...) failed: Can't connect to MySQL server on
> 'localhost' (10061) at E:/Program
> Files/ApacheGroup/Apache2/cgi-bin/testdb.pl line 17
> [Mon Aug 11 14:42:23 2003] [error] [client w.x.y.z] Can't connect to the
> DB: Can't connect to MySQL server on localhost' (10061)



Pardon if this question doesn't make sense on Windows, but who is apache
running as? Who are you running as when you do it from the command
line? Who has permissions on the named pipe?

Xho

--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service New Rate! $9.95/Month 50GB
 
Reply With Quote
 
raja babu
Guest
Posts: n/a
 
      08-13-2003
OK - I finally got it to work. And the culprit is Apache on win32.
Somehow it does always tries to connect to mySQL using TCP ( which
explains the earlier error log entry : Can't connect to MySQL server
on 'localhost' (10061) ). So, I configured mySQL to use TCP/IP and
provide the host name in the dsn variable as suggested here : my $dsn
= "dbi:mysql:database=mydatabase:host=myhostname "; - and it worked
this time.

thanks for all the replies...

rb

http://www.velocityreviews.com/forums/(E-Mail Removed) (raja babu) wrote in message news:<(E-Mail Removed). com>...
> well, I login to the machine as Administrator. The Apache config file
> ( httpd.conf ) has no mention of any user under which it is running -
> so it could be running under the Admnistrator account. When I do it
> from the command line I am running as Administrator. I do not know who
> has permissions on the named pipe - how do I find out?
>
> rb
>
> (E-Mail Removed) wrote in message news:<20030812170712.414$(E-Mail Removed)>...
>
> > Pardon if this question doesn't make sense on Windows, but who is apache
> > running as? Who are you running as when you do it from the command
> > line? Who has permissions on the named pipe?
> >
> > Xho

 
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
PERL can't open file for logging (world writable directory Windows XP Home/ Active Perl / Apache) PGPS Perl Misc 10 11-14-2006 01:40 AM
apache mod perl dbi mysql : Premature end of script headers: wana Perl Misc 0 09-17-2004 09:52 PM
#!perl instead of #!/usr/bin/perl on a Unix/Apache webserver joe Perl Misc 8 11-14-2003 10:58 AM
Use perl in apache without #!/path/to/perl Kostas Hatzikokolakis Perl Misc 2 10-19-2003 03:02 AM
How to test speed difference of Perl/Apache and SSI/Apache The Poor Perl Misc 2 09-27-2003 12:26 PM



Advertisments