首页 技术 正文
技术 2022年11月21日
0 收藏 757 点赞 4,509 浏览 1208 个字

1.给mysql创建用户备份的角色,并且授予角色SELECT, RELOAD, SHOW DATABASES, LOCK TABLES等权限。

mysql> create user 'backuper'@'localhost' identified by '********';
Query OK, rows affected (0.00 sec)mysql> grant SELECT, RELOAD, SHOW DATABASES, LOCK TABLES on *.* to backuper@localhost;
Query OK, rows affected (0.00 sec)

2.在系统中找到存储空间比较大的硬盘创建备份目录,并且创建shell脚本

[root@qxyw backup]# vim backup_qianyu_veeker_db.sh#!/bin/bash
mysqldump -ubackuper -p******** qianyu_veeker_db > /home/mysql/backup/qianyu_veeker_db_$(date +%Y%m%d_%H%M%S).sql

注意:-u和用户名中间是没有空格的,-p和密码也是这样的。

3.添加计划任务,需要安装crontab
vixie-cron 软件包是 cron 的主程序;
crontabs 软件包是用来安装、卸装、或列举用来驱动 cron 守护进程的表格的程序。

[root@qxyw ~]# yum -y install vixie-cron
[root@qxyw ~]# yum -y install crontabs

4.设置开机启动

[root@qxyw ~]# chkconfig --level 345 crond on

5.修改/etc/crontab文件,添加需要周期执行的任务

[root@qxyw etc]# crontab -eSHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/# For details see man 4 crontabs# Example of job definition:
# .---------------- minute (0 - 59)
# | .------------- hour (0 - 23)
# | | .---------- day of month (1 - 31)
# | | | .------- month (1 - 12) OR jan,feb,mar,apr ...
# | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# | | | | |
# * * * * * user-name command to be executed
0 0 * * * /home/mysql/backup/backup_qianyu_veeker_db.sh

6.启动crontab服务

[root@qxyw etc]# service crond start
Starting crond: [ OK ]
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:8,942
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,468
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,281
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,096
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,728
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,765