Hi Monks

I'm trying to write a perl script to connect to a mysql database. There're a few things which I've no answers to and as a result I'm not able to proceed. I've read the chapter on The Perl DBI API (MySQL by Paul Dubois) and tutorials from a couple of internet sites.

I just need to know how to connect to the database file(s). Here are the things I've done:

1) I've OMNI HTTPd server installed in my windows 98 box. I've no problems running my other perl cgi scripts.

2) I've installed MySQL at c:\mysql (the default directory). I've used it to create a couple of test databases so it's running ok.

3) I've installed perl DBI and perl DBD::mysql. These modules are installed at c:\perl5.6\site\lib

4) I created a script and placed it at c:\httpd\cgi-bin directory (the usual directory I put my perl cgi scripts)

5) I created a mysql test database with mysql commands. The files created reside somewhere in the mysql directory.

My questions are:

1) How do I get the script to connect to the test database I've created?

2) Do I need to move those database files from the mysql directory to the directory where the perl script is (i.e. to c:\httpd\cgi-bin)?

I'm totally lost and hope someone can point me in the right direction :)

Thanks in advance :)

In reply to Using mysql with perl by kiat

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.