If you execute mysqldump manually, mysqldump will prompt you for password. If you setup mysqldump via cronjob, you need to find a solution to disable the password. I’ve setup mysqldump to backup my db via cronjob without password. All you need to do is just to add a file in your home directory and it will disable the mysqldump password prompting.
To setup mysqldump without password in Cronjob, follow the steps below:-
Advertisements
- Start your terminal and login to your server
- Create a .my.cnf file in the home directory
vi ~/.my.cnf
- Copy the content below and replace with your mysql username and password.
[mysqldump] user = mysqluser password = secret
- Now change the file permission to 600 to prevent other user from reading it
chmod 600 ~/.my.cnf
- Now you can try to execute mysqldump and system will not prompt you for password by now
- To setup the cronjob
crontab -e
Append the line below to your crontab and it will run mysqldump every night at 12:00am
0 0 * * * mysqldump -u mysqluser -h localhost --all-databases | gzip -9 > alldb.sql.gz > /dev/null
* for more information on mysql backup, refer to how to backup mysql database
Related posts:
Secure file transfer thru scp in Mac and Linux
How to create symbolic link in Unix
How to mount samba in Mac OS X / Linux?
How to enable personal file sharing in Ubuntu 10.04
Symfony: PHP Fatal error: Call to a member function setData()
How to create bootable Linux USB drive - UNetbootin
How to move Firefox tab bar to bottom
Symfony Filter: Change ForeignKey drop down to Text field
Share this with your friends:-
Thanks, simple and a life saver
Excellent tutorial, thank you!
Great & simple post. Thanks.
Excellent post, thanks!
This is very useful.
Cheers,
-Pipe