当前位置:网站首页>Mysqldump backup database
Mysqldump backup database
2022-04-23 18:14:00 【The hunter is eating meat】
Backup
Backup myBlog database .
myBlog_back.sh:
#!/bin/bash
currentDate=$(date "+%F")
currentTime=$(date "+%Y-%m-%d_%H_%M_%S")
build_dir="/opt/db/myBlog/${currentDate}"
echo ${build_dir}
if [ ! -d "${build_dir}" ]; then
mkdir -p ${build_dir}
echo ' Directory created '
fi
/mysql/bin/mysqldump --defaults-extra-file="/opt/.mysqldump_myBlog.cnf" myBlog > ${build_dir}/myBlog_${currentTime}.sql
echo " Export succeeded "
.mysqldump_myBlog.cnf:
[client]
host='192.168.0.1'
user=root
## If the password contains special characters , Must be enclosed in quotation marks , Otherwise, you can omit
password='root'
port=3306
Restore data
## Log in to the database
mysql > mysql -uroot -p
mysql > # Input password
## Create database
mysql > create database `myBlog` default character set utf8 collate utf8_general_ci;
## Switch database
mysql > use myBlog;
## Import data
mysql > source /opt/db/myBlog/2021-03-14/myBlog_2021-03-14_21_40_01.sql
版权声明
本文为[The hunter is eating meat]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204210611118218.html
边栏推荐
- Log4j2 cross thread print traceid
- .104History
- 深度学习经典网络解析目标检测篇(一):R-CNN
- ArcGIS table to excel exceeds the upper limit, conversion failed
- Robocode tutorial 3 - Robo machine analysis
- 【ACM】70. climb stairs
- 14个py小游戏源代码分享第二弹
- ArcGIS license error -15 solution
- Multi thread crawling Marco Polo network supplier data
- Array rotation
猜你喜欢
Yolov4 pruning [with code]
Docker installation MySQL
C language loop structure program
[UDS unified diagnostic service] (Supplement) v. detailed explanation of ECU bootloader development points (1)
A few lines of code teach you to crawl lol skin pictures
Re regular expression
Robocode tutorial 3 - Robo machine analysis
idea中安装YapiUpload 插件将api接口上传到yapi文档上
Qtablewidget usage explanation
Random number generation of C #
随机推荐
C language to achieve 2048 small game direction merging logic
Re regular expression
WIN1 remote "this may be due to credssp encryption Oracle correction" solution
Docker installation MySQL
C language input and output (printf and scanf functions, putchar and getchar functions)
Secure credit
Matlab tips (6) comparison of seven filtering methods
Robocode tutorial 3 - Robo machine analysis
Nodejs installation
Clion installation tutorial
硬核解析Promise对象(这七个必会的常用API和七个关键问题你都了解吗?)
From introduction to mastery of MATLAB (2)
深度学习经典网络解析目标检测篇(一):R-CNN
ArcGIS license error -15 solution
PowerDesigner various font settings; Preview font setting; SQL font settings
Crack sliding verification code
7-21 wrong questions involve knowledge points.
消费者灰度实现思路
JD-FreeFuck 京东薅羊毛控制面板 后台命令执行漏洞
Linux installs MySQL in RPM (super simple)