Oh monks, who are wise in the ways of Perl, I need your advice. I am trying to connect to MySQL using DBI but things are going awry. I have this in my script:
my $dsn = 'DBI:mysql:ciprestest:localhost'; my $dbuser = 'cipresquery'; my $dbpass = 'iamstupid'; my $dbh = DBI->connect($dsn, $dbuser, $dbpass) or die "Couldn't connect to database: " . DBI->errstr;
But all I get is:
DBI connect('database=ciprestest;host=127.0.0.1;port=3306','',...) fai +led: Access denied for user: 'rvosa@localhost' (Using password: NO)
In other words, the user name ($dbuser) and password ($dbpass) I define seem to be ignored when DBI tries to connect, and it uses my cygwin user name (rvosa) instead. Everything works fine when I connect to mysql from the terminal: mysql -u cipresquery -p'iamstupid' ciprestest and the script does connect when I change the mysql privileges so that user name and password aren't required but that's obviously not what I want. What could be going on? I tried different permutations for quotes around the DBI->connect() arguments, concatenated them all separated by colons, tried "user=cipresquery" for $dbuser and so on but to no avail.

In reply to DBI confusion by rvosa

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.