avatar

Andres Jaimes

Storing MySQL credentials on a file

By Andres Jaimes

- 1 minutes read - 57 words

MySQL allows you to store credentials in a file called ~/.my.cnf. The contents can look like this:

[mysqldump]
user=myuser
password=mypassword

We have to modify the file permissions and give read/write permissions to the owner only:

chmod 600 ~/.my.cnf

And done. We can now use it:

mysqldump mydatabase

mysqldump is going to read the credentials from that file.