I am trying to backup my database using mysqldump and cronjobs.
Well, I added the following command to the crontab root of the user:
*/30 * * * * mysqldump -u root -pVERYSECUREPASSWORD --all-databases > /var/www/cloud/dump_komplett.sql &> /dev/null
So far this works, but the problem is that the password is specified in this command.
So, I want to include a .database.cnf file that looks like this:
[mysqldump] user=root password=VERYSECUREPASSWORD
and changed the mysqldump command to
mysqldump --defaults-extra-file="/var/crons/mysql/.database.cnf" --all-databases -u root > /var/www/cloud/dump_komplett.sql
to solve this problem.
But this command does not work with an error:
mysqldump: Got error: 1045: Access denied for user 'root'@'localhost' (using password: YES) when trying to connect
I do not know what happened.
Here are a few commands I have also tried:
mysqldump --defaults-extra-file="/var/crons/mysql/.database.cnf" --all-databases > /var/www/cloud/dump_komplett.sql mysqldump --defaults-file="/var/crons/mysql/.database.cnf" --all-databases > /var/www/cloud/dump_komplett.sql mysqldump --defaults-file="/var/crons/mysql/.database.cnf" --all-databases -u root > /var/www/cloud/dump_komplett.sql
Content
and .database.cnf I also tried:
[client] user=root password=VERYSECUREPASSWORD [mysqldump] host=localhost user=root password=VERYSECUREPASSWORD [client] host=localhost user=root password=VERYSECUREPASSWORD
mysql cron crontab mysqldump backup
Marcel balzer
source share