in reply to Re: 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)

I was away from the computer over the weekend while I saw your answer and thought Doh! but I am trying it out now and it fails as it reads the username till the end of line i.e. it includes the password as part of the username. My MariaDB version is 10.8.8 in linux.

  • Comment on Re^2: MariaDB : read credentials from file fails (via dsn option mariadb_read_default_file)

Replies are listed 'Best First'.
Re^3: MariaDB : read credentials from file fails (via dsn option mariadb_read_default_file)
by choroba (Cardinal) on Nov 06, 2023 at 17:26 UTC
    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]

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

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