Home > Database > Mysql Tutorial > body text

How to perform regular backup of CentOS7 MySQL

藏色散人
Release: 2021-11-17 15:00:28
forward
2321 people have browsed it

How to perform regular backup of CentOS7 MySQL

Data backup is really important, because one day the data may be deleted inexplicably.

This article will introduce how to use crontab and mysqldump on CentOS 7 Back up mysql data regularly.

Change the Ali source

# 备份 repo 文件
cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
# 下载
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
yum clean all # 清除缓存
yum makecache # 生成缓存
yum update
Copy after login

Install mysqldump

yum install -y mariadb
Copy after login

Scheduled tasks

Since MySQL runs in a Docker container, you cannot use socket to connect locally. You need to use the parameter -h127.0.0.1.

# 定时任务中的 % 需要使用斜杆进行转义
0 1 * * * mysqldump -uzhangsan -ppassword -h127.0.0.1 dbName > /data/dbName_`date '+\%Y\%m\%d\%H\%M\%S'`.sql 2>&1
Copy after login

Recommended study: "mysql video tutorial

The above is the detailed content of How to perform regular backup of CentOS7 MySQL. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:juejin.im
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template