Passing credentials via options file fails to read password (mariadb_read_default_file)
hadjiprocopis opened this issue · comments
I am storing DB credentials into a text file and tell the driver via the DSN string to read them. In MySQL this DSN string worked:
DBI:mysql:mysql_read_default_file=config/mysql.credentials;mysql_read_default_group=client;
with said file to contain this:
[client]
user=test
password=apass
Now, I am migrating to MariaDB and my adjusted DSN string is:
DBI:MariaDB:mariadb_read_default_file=config/mysql.credentials;mariadb_read_default_group=client;
This causes an error:
failed: Access denied for user 'test'@'localhost' (using password: NO) at ...
Please note that it reads the username correctly (test
) but does not see the password field(?).
Thank you
(Edit: I have posted the same question over at PerlMonks a few days ago: https://perlmonks.org/?node_id=11155362)
It seems to work (correct me if I'm wrong) if you use undef
instead of an empty string for the password in the connect
incantation.
Thank you choroba++ that did it!
And sorry I saw your solution at PerlMonks (https://perlmonks.org/?node_id=11155413 too late.
I think the solution provided by choroba resolves my issue. thank you.