Press enter to see results or esc to cancel.


Auto Back up Mysql Database without any Software

This tutorial shows how to take back up of a MySql Database without any software. This can be done by creating a scheduled task with a Bat file. Here is the Step by Step process for that.

  1. If you want to a auto back up Mysql database test_111 as shown below
  2. First we will check how to manually take back up of the database test_111 , For that open Command Prompt and navigate to the location where you have installed MySql.
    The default MySql install directory is C:\Program Files (x86)\MySQL\MySQL Server 5.0\bin.
    So open CMD and Navigate to this location by typing command

    cd "C:\Program Files (x86)\MySQL\MySQL Server 5.0\bin"

  3. Now execute the below command, Update the username and password before executing the command. I have set it username and password as root because it is my credentials of MySql database.
    mysqldump -hlocalhost -uroot -proot test_111 > "C:\Users\MIRITPC\Desktop\back up folder\test_111_backup.sql"
    

    After executing the command it will create a Back up of database in the folder specified in the command. ie.
    C:\Users\MIRITPC\Desktop\back up folder\test_111_backup.sql, You can change any where you want.

  4. Now lets automate the back up process, For that create a Bat file. First open a new notepad file and copy the below code and save the notepad with .bat extension.

    cd "C:\Program Files (x86)\MySQL\MySQL Server 5.0\bin"
    mysqldump -hlocalhost -uroot -proot test_111 > "C:\Users\MIRITPC\Desktop\back up folder\test_111_backup.sql"
        

    Copy paste the above code

  5. Save the text file with bat extension

    Save the bat file anywhere safer place in your PC

    Now if you try to open the bat bat file it will create the back up of the Database in the folder we specified.




  6. To automate the process to execute the bat file on regular intervals you have to create task scheduler in Windows. For that follow the steps below
    Open Task scheduler
  7. Click on Create Task
  8. Give any name for the task
  9. 1. Click on Triggers Tab
    2. Click New Button
    3. Select your interval you want. I am selecting Daily and set time as 12.00 AM. So that every day at 12 AM it will execute the bat file to take back up
    4. Set your back up time
  10. 1. Click on Actions Tab
    2. Click New Button
    3. Select Action as Start a program and in Program/script navigate the location where you saved the Bat file and Click OK
  11. 1. Now the task will be listed there on Task Scheduler Library
    2. To test the process you can immediately run the process by clicking RUN button
  12. After creating the task. The auto back process will run every day on the preset time.
    If you want to stop the process you have to delete the task from task scheduler.Please not that the bat file should be always available for the process. Don’t delete it.
    If you have any doubt in this please comment below.


Tags