mysql supports passwordless login using stored local authentication credentials in a file named .mylogin.cnf (see here for more details).
for example:
mysql --login-path=local
My questions is: how to do this in perl using DBD::mysql?
mysql supports passwordless login using stored local authentication credentials in a file named .mylogin.cnf (see here for more details).
for example:
mysql --login-path=local
My questions is: how to do this in perl using DBD::mysql?
DBD::mysql uses the MySQL C API, which doesn't appear to support login paths. As an alternative, you can use an option file and the
mysql_read_default_file
andmysql_read_default_group
options in yourconnect
call:Your option file should look something like this:
Note that unlike .mylogin.cnf (the file used by
--login-path
), regular option files are not encrypted. This isn't as big of a problem as it might sound. The main benefit of encryption is that it prevents you from accidentally exposing your credentials, e.g. when viewing the file, but it doesn't provide unbreakable security. You can still protect your option file by making sure it's not world-readable, excluding it from version control, etc.