Storing MySQL password in .my.cnf

Create ~/.my.cnf file

touch ~/.my.cnf
chmod 700 ~/.my.cnf

Edit file

vi ~/.my.cnf

Add following content

[client]
user = root
password = DBPASSWORD

[mysqladmin]
user = root
password = DBPASSWORD

[mysqldump]
user = root
password = DBPASSWORD

Now you will be able to login to server with out password.


Posted in MySQL