I was wondering what is the best way to store usernames and password to connect to mysql database?
MySQL server uses the PASSWORD function to encrypt MySQL passwords for storage in the Password column of the user grant table. The value returned by the PASSWORD function is a hashed string, or NULL if the argument was NULL. The PASSWORD function accepts one parameter which is the string to be encrypted.
MySQL passwords for users are stored within MySQL itself; they are stored in the mysql. user table. The passwords are hashed by default using the PASSWORD() function.
An easy and safe way — if you do it right — is with a config file. The DBI/DBD MySQL connection string will look something like–
dbi:mysql:my_dbname;mysql_read_default_file=/NON-WEB/path/to/.my.cnf
–and you will pass no user or password to the DBI connection call.
The .my.cnf file will have the password. The ways to keep this safe include–
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With