perl + mysql + apache on windows

Ask a Question related to PERL Miscellaneous, Design and Development.

  1. #1

    Default perl + mysql + apache on windows


    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


    RB Guest

  2. Similar Questions and Discussions

    1. which server for PHP, Mysql and apache for windows?
      I'd like to install a server for PHP, Mysql and Apache. I use Phpdev but there is a problem: how do not allow the access to mysql by phpMyAdmin? I...
    2. Off Topic: Active Perl Native Windows / cygwin perl
      I have both activestate windows native perl installed and the default cygwin perl. How can I have the cygwin shell use the windows perl rather...
    3. Configuring Jpgraph on Windows 2000+Apache+PHP+MySql server
      Could someone walk me step by step on how to install and get JpGraph running on a Windows 2000+Apache+PHP+MySql server? -Thanks Jeff
    4. Need Install instructions for PHP, MySQL, and Apache on Windows OS.
      Dear Colleagues: In need help in finding install instructions for PHP, MySQL, and Apache on Windows OS. Thanks for your help! Regards, Taino
    5. Windows 2k, Apache, MySQL, PHP 4.3.2, Smarty
      Problem with Smarty. My application is giving me an error when i try to use smarty on a new WAMP install. Smarty is in my include path. Getting...
  3. #2

    Default Re: perl + mysql + apache on windows

    Hello,

    "RB" <raja_babu0@lycos.com> wrote in message
    news:Usb_a.175998$rsJ.6273@news04.bloor.is.net.cab 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


    Mothra Guest

  4. #3

    Default Re: perl + mysql + apache on windows

    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: [url]http://www.gunnar.cc/cgi-bin/contact.pl[/url]

    Gunnar Hjalmarsson Guest

  5. #4

    Default Re: perl + mysql + apache on windows

    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" <mothra@nowhereatall.com> wrote in message
    news:3f37f83e$1@usenet.ugs.com...
    > Hello,
    >
    > "RB" <raja_babu0@lycos.com> wrote in message
    > news:Usb_a.175998$rsJ.6273@news04.bloor.is.net.cab 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
    >
    >

    RB Guest

  6. #5

    Default Re: perl + mysql + apache on windows

    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" <noreply@gunnar.cc> wrote in message
    news:bhbhcb$10b5a5$1@ID-184292.news.uni-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: [url]http://www.gunnar.cc/cgi-bin/contact.pl[/url]
    >

    RB Guest

  7. #6

    Default Re: perl + mysql + apache on windows

    Please do not top post. It anoys the regulars here
    [text rearranged]

    "RB" <raja_babu0@lycos.com> wrote in message
    news:NVb_a.176187$rsJ.40778@news04.bloor.is.net.ca ble.rogers.com...
    > "Mothra" <mothra@nowhereatall.com> wrote in message
    > news:3f37f83e$1@usenet.ugs.com...
    > > Hello,
    > >
    > > "RB" <raja_babu0@lycos.com> wrote in message
    > > news:Usb_a.175998$rsJ.6273@news04.bloor.is.net.cab 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" <raja_babu0@lycos.com> 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


    Mothra Guest

  8. #7

    Default Re: perl + mysql + apache on windows

    "RB" <raja_babu0@lycos.com> 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

    --
    -------------------- [url]http://NewsReader.Com/[/url] --------------------
    Usenet Newsgroup Service New Rate! $9.95/Month 50GB
    ctcgag@hotmail.com Guest

  9. #8

    Default Re: perl + mysql + apache on windows

    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

    [email]raja_babu0@lycos.com[/email] (raja babu) wrote in message news:<67505fb2.0308130454.52dfd55c@posting.google. 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
    >
    > [email]ctcgag@hotmail.com[/email] wrote in message news:<20030812170712.414$aG@newsreader.com>...
    >
    > > 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
    raja babu Guest

  10. #9

    Thumbs up Re: perl + mysql + apache on windows

    This problem is due to some problem with environment variable....
    and thus apache tomcat is not able to connect to the mysql

    Do the following to solve the problem.....




    Open [tomcat home]/conf/web.xml

    You will find following code :::::::::::::

    <servlet>
    <servlet-name>cgi</servlet-name>
    <servlet-class>org.apache.catalina.servlets.CGIServlet</servlet-class>
    <init-param>
    <param-name>debug</param-name>
    <param-value>0</param-value>
    </init-param>
    <init-param>
    <param-name>cgiPathPrefix</param-name>
    <param-value>WEB-INF/cgi</param-value>
    </init-param>
    <load-on-startup>5</load-on-startup>
    </servlet>



    In this code add the following code::::::

    <init-param>
    <param-name>passShellEnvironment</param-name>
    <param-value>true</param-value>
    </init-param>



    So the resulting code will be :::::::::::::

    <servlet>
    <servlet-name>cgi</servlet-name>
    <servlet-class>org.apache.catalina.servlets.CGIServlet</servlet-class>
    <init-param>
    <param-name>debug</param-name>
    <param-value>0</param-value>
    </init-param>
    <init-param>
    <param-name>cgiPathPrefix</param-name>
    <param-value>WEB-INF/cgi</param-value>
    </init-param>
    <init-param>
    <param-name>passShellEnvironment</param-name>
    <param-value>true</param-value>
    </init-param>
    <load-on-startup>5</load-on-startup>
    </servlet>



    Now save the web.xml file and restart your apache tomcat server.
    And now run your perl-cgi page containing code to connect to the MySQL
    You are done... :-)
    Ravi Patel Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139