MySQL Database Backups via Crojob Without Exposing Password

Keywords: LAMP/MAMP/WAMP - AWS - Technical issue - Other
bnsupport ID: 253614f3-758d-610d-5742-82df8f0ffaff
I have read:

What I want to accomplish

  • Command-line cron jobs to run backups every day at midnight
  • Running said cron job without exposing the password

Hello @rdorn,

sudo crontab -e
00 00 * * * /opt/bitnami/mysql/bin/mysqldump -uroot -pYOUR_PASSWORD YOUR_DATABASE > /PATH_TO_YOUR_MYSQLDUMP/mysqldump-$(date +"%m-%d-%y")

The command below will execute a backup every day at 00:00 with name mysqldump-DATE (e.g. mysqldump-05-28-21). Note you need to update YOUR_PASSWORD, YOUR_DATABASE, and PATH_TO_YOUR_MYSQLDUMP placeholders.

This editor is only accessible by root.

Alternatively, you could add these lines to your /opt/bitnami/mysql/conf/my.cnf:


and restart apache (sudo /opt/bitnami/ restart mysql). This lets you use mysqldump without having to actually enter the password. Then, you could use:

00 00 * * * /opt/bitnami/mysql/bin/mysqldump -uroot  YOUR_DATABASE > /PATH_TO_YOUR_MYSQLDUMP/mysqldump-$(date +"%m-%d-%y")

This page could be useful:


This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.