How to setup mysqldump without password in cronjob


mysql, mysql databaseIf 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:-

  • Start your terminal and login to your server
  • Create a .my.cnf file in the home directory
  • Copy the content below and replace with your mysql username and password.
  • Now change the file permission to 600 to prevent other user from reading it
  • Now you can try to execute mysqldump and system will not prompt you for password by now
  • To setup the cronjob

    Append the line below to your crontab and it will run mysqldump every night at 12:00am

* for more information on mysql backup, refer to how to backup mysql database

Related posts:

Mod Security - Open source Web Application Firewall
How to install LAMP (Apache, PHP and MySQL in Linux) using Yum
Linux - How to check memory usage
How to check Linux distribution and version?
How to import contacts from SIM card to nokia N900
How to enable personal file sharing in Ubuntu 10.04
How to check Zimbra Version without ssh access?
How to hide apache2 version number in error page

4 Responses to “How to setup mysqldump without password in cronjob”

  1. littleguy says:

    Excellent tutorial, thank you!

  2. Jody says:

    Great & simple post. Thanks.

  3. littleguy says:

    Excellent post, thanks!

  4. sivawut srithammawut says:

    This is very useful.


Leave a Reply