Linux auto-login on MySQL

Create file ~/.my.cnf and add the following lines, replace mysqluser and mysqlpass values with the correct ones

[client]
user=mysqluser
password="mysqlpass"

For safety, make this file readable to you only by running chmod 0600 ~/.my.cnf 

Next time you run mysql commands mysql, mysqlcheck, mysqdump, etc; they will pick username & password from this file if you do not provide them as argument (-u and -p). It can save your time.

Of-course, if you specify username and password explicitly as part of commands arguments, they will be used.

https://easyengine.io/tutorials/mysql/mycnf-preference/

Back to top