Home > Database > Mysql Tutorial > body text

Mysql simple full backup and quick recovery method

藏色散人
Release: 2020-03-11 08:53:05
forward
2249 people have browsed it

A simple mysql full backup script to back up the data of the last 15 days.

Backup

#每天备份mysql数据库(保存最近15天的数据脚本)
DATE=$(date +%Y%m%d)
/home/cuixiaohuan/lamp/mysql5/bin/mysqldump -uuser -ppassword need_db > /home/cuixiaohuan/bak_sql/mysql_dbxx_$DATE.sql;
find /home/cuixiaohuan/bak_sql/ -mtime +15 -name '*.sql' -exec rm -rf {} \;
Copy after login

Restore

mysql data import

drop databases need_db;
create databases need_db;
Copy after login

Import data: encoding must be set Recover

./mysql -uroot -p --default-character-set=utf8 need_db < xx.sql
Copy after login

Recommend learning mysql video tutorial: https://www.php.cn/course/list/51.html

The above is the detailed content of Mysql simple full backup and quick recovery method. 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