Home > Database > Mysql Tutorial > body text

A brief analysis of how to regularly back up mysql data in CentOS 7?

青灯夜游
Release: 2021-10-11 15:16:08
forward
1729 people have browsed it

How to regularly back up mysql data in CentOS 7? The following article will introduce to you the method of regularly backing up mysql data in CentOS 7. I hope it will be helpful to you!

A brief analysis of how to regularly back up mysql data in CentOS 7?

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

This article will introduce how to restore the system in CentOS Use crontab and mysqldump on 7 to regularly back up the data of mysql. [Related recommendations: mysql video tutorial]

Change 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

Installationmysqldump

yum install -y mariadb
Copy after login

Scheduled tasks

Since MySQL is running in the Docker container, it cannot be used locallysocket To connect, 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

Original link: https://goworker.cn/posts/mysql- data-backup/

For more programming-related knowledge, please visit: Programming Video! !

The above is the detailed content of A brief analysis of how to regularly back up mysql data in CentOS 7?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:segmentfault.com
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