I want to take a mysql database backup of my wordpress sites. So i created i bash script for this purpose but what is the best case to deal with db password?
Case1: use .my.cnf to store password for every site and call it like this
“mysqldump --defaults-file=/home/hestiacpuser/web/mydomain.com/.my.cnf -u ${DBUSER} ${DATABASE} > sqlbackup.sql”
Case2: use .my.cnf for root user and take db backups as mysql root user?
Case3: take database credentials from wp-config.php file using code like this
“WPDBPASS=”$(cat ./wp-config.php | grep DB_PASSWORD | cut -d ' -f 4)"
Case 3 is less secure but as db credentials are stored as plain text in wp-config.php file. Are there any additional risks? What if i unset the variable WPDBPASS?
Thanks
edit 1. I checked mysql root password and found that it isnt very complex. it is something like this “erkmnftsfl” (only letters)