{"id":61,"date":"2017-10-21T18:02:40","date_gmt":"2017-10-21T18:02:40","guid":{"rendered":"https:\/\/standingtech.com\/randomarticles\/?p=61"},"modified":"2017-10-21T18:43:43","modified_gmt":"2017-10-21T18:43:43","slug":"automatically-backup-mysql-databases-on-windows","status":"publish","type":"post","link":"https:\/\/standingtech.com\/randomarticles\/automatically-backup-mysql-databases-on-windows\/","title":{"rendered":"Automatically Backup MySQL Databases on Windows"},"content":{"rendered":"<h3>MySQL Command for backup all databases:<\/h3>\n<p><strong>mysqldump -uUSERNAME -pPASSWORD &#8211;all-databases &gt; &#8220;D:\/File_NAME_%date:~-4,4%-%date:~-10,2%-%date:~-7,2%-%time:~0,2%_%time:~3,2%_%time:~6,2%.sql&#8221;<\/strong><\/p>\n<p><strong>Example:<\/strong><\/p>\n<p>Consider MySQL username = root and password = 123456<\/p>\n<p><strong>mysqldump -uroot -p123456 &#8211;all-databases &gt; &#8220;D:\/mysql_backup_%date:~-4,4%-%date:~-10,2%-%date:~-7,2%-%time:~0,2%_%time:~3,2%_%time:~6,2%.sql&#8221;<\/strong><\/p>\n<p>The result will be a file name (mysql_backup_2017-10-21-20_29_54.sql) containing all databases.<\/p>\n<h3>MySQL Command for one database databases:<\/h3>\n<p><strong>mysqldump -uroot -p123456 &#8211;databases <em>mydatabasename<\/em> &gt; &#8220;D:\/mysql_backup_%date:~-4,4%-%date:~-10,2%-%date:~-7,2%-%time:~0,2%_%time:~3,2%_%time:~6,2%.sql&#8221;<\/strong><\/p>\n<p>We replaced &#8211;all-databases with <strong>&#8211;databases databasename <\/strong><\/p>\n<p><strong>Note the date format:<\/strong><\/p>\n<ul>\n<li>%date:~-4,4%: year 4 digits<\/li>\n<li>%date:~-10,2%: month 2 digits<\/li>\n<li>%date:~-7,2%: day 2 digits<\/li>\n<li>%time:~0,2%: time in 24 hours format<\/li>\n<li>%time:~3,2%: minutes 2 digits<\/li>\n<li>%time:~6,2%: seconds 2 digits<\/li>\n<\/ul>\n<p>Now, after you customized the file name and date format, save your last command in file with (.bat) extension for examle:<\/p>\n<p><strong>mysqk-backup.bat<\/strong><\/p>\n<p>And put the file in local C: drive inside windows or any where in safe place of which normal user will not delete it, and then<\/p>\n<ol>\n<li>Press windows key + R to open Run windows and then type <strong>taskschd.msc<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"foobox alignnone wp-image-62 \" src=\"https:\/\/standingtech.com\/randomarticles\/wp-content\/uploads\/2017\/10\/run.png\" alt=\"Windows Run\" width=\"418\" height=\"246\" srcset=\"https:\/\/standingtech.com\/randomarticles\/wp-content\/uploads\/2017\/10\/run.png 749w, https:\/\/standingtech.com\/randomarticles\/wp-content\/uploads\/2017\/10\/run-416x245.png 416w, https:\/\/standingtech.com\/randomarticles\/wp-content\/uploads\/2017\/10\/run-300x177.png 300w\" sizes=\"auto, (max-width: 418px) 100vw, 418px\" \/><\/strong><\/li>\n<li>Once the Task Scheduler opened, Create New Task (located at the right sidebar) or go to <strong>Action<\/strong> menu and then Create Task<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"foobox alignnone wp-image-63 size-large\" src=\"https:\/\/standingtech.com\/randomarticles\/wp-content\/uploads\/2017\/10\/task1-1024x675.png\" alt=\"Task Scheduler\" width=\"640\" height=\"422\" srcset=\"https:\/\/standingtech.com\/randomarticles\/wp-content\/uploads\/2017\/10\/task1-1024x675.png 1024w, https:\/\/standingtech.com\/randomarticles\/wp-content\/uploads\/2017\/10\/task1-416x274.png 416w, https:\/\/standingtech.com\/randomarticles\/wp-content\/uploads\/2017\/10\/task1-300x198.png 300w, https:\/\/standingtech.com\/randomarticles\/wp-content\/uploads\/2017\/10\/task1-768x506.png 768w, https:\/\/standingtech.com\/randomarticles\/wp-content\/uploads\/2017\/10\/task1.png 1709w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/li>\n<li>The task creation menu will open, first in General Tab, Fill name of the task (MySQL Database Backup &#8211; Daily)<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"foobox alignnone wp-image-64 size-large\" src=\"https:\/\/standingtech.com\/randomarticles\/wp-content\/uploads\/2017\/10\/task1-1-1024x784.png\" alt=\"Task Scheduler General Tab\" width=\"640\" height=\"490\" srcset=\"https:\/\/standingtech.com\/randomarticles\/wp-content\/uploads\/2017\/10\/task1-1-1024x784.png 1024w, https:\/\/standingtech.com\/randomarticles\/wp-content\/uploads\/2017\/10\/task1-1-416x319.png 416w, https:\/\/standingtech.com\/randomarticles\/wp-content\/uploads\/2017\/10\/task1-1-300x230.png 300w, https:\/\/standingtech.com\/randomarticles\/wp-content\/uploads\/2017\/10\/task1-1-768x588.png 768w, https:\/\/standingtech.com\/randomarticles\/wp-content\/uploads\/2017\/10\/task1-1.png 1260w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/li>\n<li>Then Click on Triggers tab and Then New.. to create new trigger (This is where you set your schedule plan)<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"foobox alignnone wp-image-65 size-large\" src=\"https:\/\/standingtech.com\/randomarticles\/wp-content\/uploads\/2017\/10\/task1-2-1024x894.png\" alt=\"Task Scheduler Trigger\" width=\"640\" height=\"559\" srcset=\"https:\/\/standingtech.com\/randomarticles\/wp-content\/uploads\/2017\/10\/task1-2-1024x894.png 1024w, https:\/\/standingtech.com\/randomarticles\/wp-content\/uploads\/2017\/10\/task1-2-416x363.png 416w, https:\/\/standingtech.com\/randomarticles\/wp-content\/uploads\/2017\/10\/task1-2-300x262.png 300w, https:\/\/standingtech.com\/randomarticles\/wp-content\/uploads\/2017\/10\/task1-2-768x671.png 768w, https:\/\/standingtech.com\/randomarticles\/wp-content\/uploads\/2017\/10\/task1-2.png 1182w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/li>\n<li>Then Click Ok, and now go to Actions tab<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"foobox alignnone wp-image-67 size-large\" src=\"https:\/\/standingtech.com\/randomarticles\/wp-content\/uploads\/2017\/10\/task1-3-1024x774.png\" alt=\"Task Scheduler New Action\" width=\"640\" height=\"484\" srcset=\"https:\/\/standingtech.com\/randomarticles\/wp-content\/uploads\/2017\/10\/task1-3-1024x774.png 1024w, https:\/\/standingtech.com\/randomarticles\/wp-content\/uploads\/2017\/10\/task1-3-416x315.png 416w, https:\/\/standingtech.com\/randomarticles\/wp-content\/uploads\/2017\/10\/task1-3-300x227.png 300w, https:\/\/standingtech.com\/randomarticles\/wp-content\/uploads\/2017\/10\/task1-3-768x581.png 768w, https:\/\/standingtech.com\/randomarticles\/wp-content\/uploads\/2017\/10\/task1-3.png 1264w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/li>\n<li>Then Click on New.. once the window opened, browser to your file that we mentioned above, in our example we used (<strong>mysqk-backup.bat)<br \/>\n<\/strong><img loading=\"lazy\" decoding=\"async\" class=\"foobox alignnone wp-image-68 \" src=\"https:\/\/standingtech.com\/randomarticles\/wp-content\/uploads\/2017\/10\/task1-4.png\" alt=\"Task Scheduler New Action\" width=\"484\" height=\"533\" srcset=\"https:\/\/standingtech.com\/randomarticles\/wp-content\/uploads\/2017\/10\/task1-4.png 908w, https:\/\/standingtech.com\/randomarticles\/wp-content\/uploads\/2017\/10\/task1-4-416x458.png 416w, https:\/\/standingtech.com\/randomarticles\/wp-content\/uploads\/2017\/10\/task1-4-272x300.png 272w, https:\/\/standingtech.com\/randomarticles\/wp-content\/uploads\/2017\/10\/task1-4-768x846.png 768w\" sizes=\"auto, (max-width: 484px) 100vw, 484px\" \/><\/li>\n<li>Then click ok!, and again Click Ok to save everything.<\/li>\n<li>You can now right click on this task and click run to test if everything works fine.<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>MySQL Command for backup all databases: mysqldump -uUSERNAME -pPASSWORD &#8211;all-databases &gt; &#8220;D:\/File_NAME_%date:~-4,4%-%date:~-10,2%-%date:~-7,2%-%time:~0,2%_%time:~3,2%_%time:~6,2%.sql&#8221; Example: Consider MySQL username = root and password = 123456 mysqldump -uroot -p123456 &#8211;all-databases &gt; &#8220;D:\/mysql_backup_%date:~-4,4%-%date:~-10,2%-%date:~-7,2%-%time:~0,2%_%time:~3,2%_%time:~6,2%.sql&#8221; The result will be a file name (mysql_backup_2017-10-21-20_29_54.sql) containing all databases. MySQL Command for one database databases: mysqldump -uroot -p123456 &#8211;databases mydatabasename &gt; &#8220;D:\/mysql_backup_%date:~-4,4%-%date:~-10,2%-%date:~-7,2%-%time:~0,2%_%time:~3,2%_%time:~6,2%.sql&#8221; We replaced &#8211;all-databases&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10,5,9],"tags":[17,16,19,20,18],"class_list":["post-61","post","type-post","status-publish","format-standard","hentry","category-database","category-security","category-web-design","tag-backup","tag-mysql","tag-mysql-command","tag-task-scheduler","tag-windows-schedule"],"_links":{"self":[{"href":"https:\/\/standingtech.com\/randomarticles\/wp-json\/wp\/v2\/posts\/61","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/standingtech.com\/randomarticles\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/standingtech.com\/randomarticles\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/standingtech.com\/randomarticles\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/standingtech.com\/randomarticles\/wp-json\/wp\/v2\/comments?post=61"}],"version-history":[{"count":5,"href":"https:\/\/standingtech.com\/randomarticles\/wp-json\/wp\/v2\/posts\/61\/revisions"}],"predecessor-version":[{"id":73,"href":"https:\/\/standingtech.com\/randomarticles\/wp-json\/wp\/v2\/posts\/61\/revisions\/73"}],"wp:attachment":[{"href":"https:\/\/standingtech.com\/randomarticles\/wp-json\/wp\/v2\/media?parent=61"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/standingtech.com\/randomarticles\/wp-json\/wp\/v2\/categories?post=61"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/standingtech.com\/randomarticles\/wp-json\/wp\/v2\/tags?post=61"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}