in reply to Re^2: MariaDB : read credentials from file fails (via dsn option mariadb_read_default_file)
in thread MariaDB : read credentials from file fails (via dsn option mariadb_read_default_file)

You are right, of course. I'm sorry for the confusion.

But I think I've found the solution. The format of the file is OK with a newline, the problem is the invocation of the connect method: if you specify an empty string for the password, it has precedence over the one specified in the config. You need to specify undef for the password to get it replaced by the configuration value.

my @dsns = ( $dsn, '', # username is read from file undef, # password is read from file!! {RaiseError => 1, PrintError => 1} );
map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]
  • Comment on Re^3: MariaDB : read credentials from file fails (via dsn option mariadb_read_default_file)
  • Select or Download Code

Replies are listed 'Best First'.
Re^4: MariaDB : read credentials from file fails (via dsn option mariadb_read_default_file)
by bliako (Abbot) on Nov 06, 2023 at 22:11 UTC

    Thank you choroba++ your solution works! And it makes sense too.

Re^4: MariaDB : read credentials from file fails (via dsn option mariadb_read_default_file)
by bliako (Abbot) on Nov 06, 2023 at 22:13 UTC

    Thank you choroba++ your solution works! And it makes sense too.