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

Summary of problems encountered when installing docker on win10 home version

Docker download address: http://get.daocloud.io/#...

MySQL Server 8.0.13.0 Installation Tutorial with Pictures and Text

Install 8.0.13 based on MySQL 6.1.3. MySQL 8.0.13...

How to use MySQL limit and solve the problem of large paging

Preface In daily development, when we use MySQL t...

CSS beginner tutorial: background image fills the entire screen

If you want the entire interface to have a backgr...

MySQL example of getting today and yesterday's 0:00 timestamp

As shown below: Yesterday: UNIX_TIMESTAMP(CAST(SY...

CSS to achieve floating customer service effect

<div class="sideBar"> <div>...

HTML Tutorial: Collection of commonly used HTML tags (5)

These introduced HTML tags do not necessarily ful...

My personal summary of mysql 5.7 database installation steps

1.mysql-5.7.19-winx64.zip (this is the free insta...

Summary of MySql index, lock, and transaction knowledge points

This article summarizes the knowledge points of M...

How to configure VMware virtual machine NAT mode

This article describes the VMware virtual machine...

How to create a table by month in MySQL stored procedure

Without going into details, let's go straight...

Example of using #include file in html

There are two files a.htm and b.htm. In the same d...

MySQL data type selection principles

Table of contents Small but beautiful Keep it sim...

Detailed steps to install Anaconda on Linux (Ubuntu 18.04)

Anaconda is the most popular python data science ...