Implementation of scheduled backup in Mysql5.7

Implementation of scheduled backup in Mysql5.7

1. Find mysqldump.exe in the MySQL installation path D:\xxx\MYSQL\MySQL Workbench CE 6.0.8. Since the script execution requires that there should be no spaces in the path (if there are spaces in the path, a 0kb backup file will be generated), copy mysqldump.exe to any folder (here I am D:/Soft/MYSQL)

2. Edit and save the script back_up.bat as follows:

@echo off
set "Ymd=%date:~,4%%date:~5,2%%date:~8,2%"
D:/Soft/MYSQL/mysqldump --opt -u root --password=991446 lslib_test> D:/db_backup/lslib_test_%Ymd%.sql
@echo on

Note: This method does not require closing the database, and can back up files by name every day.

The current date is obtained by combining %date:~5,2%. The effect of the combination is yyyymmdd. The date format obtained by the date command defaults to yyyy-mm-dd (if it is not in this format, you can use the pause command to pause the command line window to view the current computer date format obtained by %date:~,20%). Therefore, %date:~5,2% can be used to get the two characters starting from the fifth character in the date. For example, today is 2009-02-05, and %date:~5,2% can be used to get 02. (The subscript of the date string starts from 0)!

2. Put the script back_up.bat into the Windows execution plan

Control Panel -> Search for Scheduled Tasks -> Create Basic Tasks -> Follow your instincts and you can configure it successfully!

Replenish:

The above method works fine on my local machine, but the same setting on the server is unsuccessful, so I used navicat scheduled tasks to do a scheduled backup.

step:

1. Open Navicat, click Backup - New Backup, click Save without using anything, give it a name and close the dialog box. All tables are checked by default in Object Selection.

2. Click Plan -> Create a new batch job -> Double-click the plan you want to select (the plan saved in the previous step)

3. Save the plan (give it a random name) --> click the task to be executed --> set the scheduled task

4. Set the scheduled time and save it. The password you are required to enter is the server password.

5. After success, the scheduled backup will generate a psc file. The default location is C:\Users\Computer Name\Documents\Navicat\MySQL\servers, which can be seen in the backup of the navicat table.

6. You can modify the backup storage location

At this time, when I use navicat to extract SQL, I get garbled characters. It is normal to restore the backup directly.

QA: The script scheduling task can be done locally but not on the server. Why? Navicat scheduled tasks cannot be done on the local machine, but can be done on the server. Why? Why is there garbled Chinese characters when extracting SQL? UTF-8 and GBK encoding formats don't work either. Why?

This is the end of this article about the implementation of scheduled backup in MySQL 5.7. For more information about scheduled backup in MySQL, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • Detailed steps for configuring mysql8.0.20 with binlog2sql and simple backup and recovery
  • Shell script to backup MySQL database data regularly and retain it for a specified time
  • A brief analysis of MySQL backup and recovery
  • Detailed explanation of mysql backup and recovery
  • MySQL scheduled backup solution (using Linux crontab)
  • How to implement scheduled backup of CentOS MySQL database
  • MySQL database backup and recovery method
  • Detailed explanation of three ways to backup mysql
  • Detailed explanation of mysqldump backup and restore and mysqldump import and export statements
  • How to use mysqldump to backup and restore specified tables
  • Notes on the MySQL database backup process

<<:  Vue template compilation details

>>:  Implementation of Docker Compose multi-container deployment

Recommend

Implement full screen and monitor exit full screen in Vue

Table of contents Preface: Implementation steps: ...

The difference between absolute path and relative path in web page creation

1. Absolute path First of all, on the local compu...

Installation and use of mysql mycat middleware

1. What is mycat A completely open source large d...

Analysis of the ideas of implementing vertical tables in two ways in Vue project

Problem Description In our projects, horizontal t...

WePY cloud development practice in Linux command query applet

Hello everyone, today I will share with you the W...

How to build gitlab on centos6

Preface The original project was placed on the pu...

Vue simulates the shopping cart settlement function

This article example shares the specific code of ...

Docker swarm simple tutorial

swarm three virtual machines 132,133,134 1. Initi...

HTML uncommon tags optgroup, sub, sup and bdo example code

Optgroup is used in the select tag to make the dro...

Detailed explanation of Vue's hash jump principle

Table of contents The difference between hash and...

WeChat Mini Programs Implement Star Rating

This article shares the specific code for WeChat ...

Example of using Vue built-in component keep-alive

Table of contents 1. Usage of keep-alive Example ...

The impact of limit on query performance in MySQL

I. Introduction First, let me explain the version...