Setting up to not need password for root and MySqlDump


Setup mysqldump to not need password in the terminal or bash script


Login as root if you are not already.


$ su
password: ******


or for some servers ( for instance default Debian 9 on AWS)


$ sudo -i


Create a ".my.cnf" file in the home directory.


# cd ~
# nano .my.cnf


Copy the content below and replace with your mysql username and password


[mysqldump]
user = root
password = secret


Save the file and exit nano.


Now change the file permission to 600 to prevent other users from reading it:


# chmod 0600 ~/.my.cnf


Now when you execute mysqldump as root the system will not prompt you for password.


Related

Getting Started

Configuring MariaDB with my.cnf

MySql Using Option Files