Wise Monks,

I am migrating from MySQL to MariaDB and my usual Perl DBD dsn which reads credentials from file (instead of storing/hardcoding then in perl code) fails.

Previously, with MySQL, the connection drill was something like:

my $dsn = 'DBI:mysql:database=testdb;mysql_read_default_file=creds.txt +'; my @dsns = ( $dsn, '', # username is read from file '', # password is read from file {"RaiseError" => 1, "PrintError" => 1} ); my $dbh = eval { DBI->connect(@dsns) }; die $@ if $@;

Where the credentials file creds.txt reads like this:

[client] user=testuser password=apass

Above code is equivalent to running mysql client on the command line like mysql --defaults-extra-file="creds.txt". This command logs me in the DB fine from the CLI.

Now, modifying the dsn a bit for DBD::MariaDB:

my $dsn = 'DBI:MariaDB:database=testdb;mariadb_read_default_file=creds +.txt'; ...

Fails with failed: Access denied for user 'testuser'@'localhost' (using password: NO). Notice that it reads the username (testuser) correctly from the file. But ignores(?) the password. But using the CLI interface it logs me in fine (reads both username and password).

It is also weird that if I give it a fake file in the dsn above, it does not say (using password: NO). And the username is my login name. All these make me think that all works fine except from reading the password. Any hints?

thank you // bw, bliako


In reply to MariaDB : read credentials from file fails (via dsn option mariadb_read_default_file) by bliako

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.