全量: [root@masterleo]#catDBfullBak.sh#!/bin/bash#usemysqldumptofullybackupmysqldataBakDir=/root/leo/fullLogFile=/root/leo/full/bak.logDate=`date+%Y%m%d`Begin=`date+"%Y年%m月%d日%H:%M:%S"`cd$BakDirDumpFile=$Date.sqlGZDumpFile=$Date.sql.tg
全量:
[root@master leo]# cat DBfullBak.sh #!/bin/bash #use mysqldump to fully backup mysql data BakDir=/root/leo/full LogFile=/root/leo/full/bak.log Date=`date +%Y%m%d` Begin=`date +"%Y年%m月%d日 %H:%M:%S"` cd $BakDir DumpFile=$Date.sql GZDumpFile=$Date.sql.tgz mysqldump -uroot -p123456 --all-databases --lock-all-tables --routines --triggers --events --master-data=2 --flush-logs > $DumpFile tar zcvf $GZDumpFile $DumpFile rm $DumpFile Last=`date +"%Y年%m月%d日 %H:%M:%S"` echo 开始:$Begin 结束:$Last $GZDumpFile succ >> $LogFile
参数注释:
--all-databases #备份所有库 --lock-all-tables #为所有表加读锁 --routinge #存储过程与函数 --triggers #触发器 --events #记录事件 --master-data=2 #在备份文件中记录当前二进制日志的位置,并且为注释的,1是不注释掉在主从复制中才有意义 --flush-logs #日志滚动一次
结果如下:
[root@master full]# ls 20140728.sql.tgz bak.log [root@master full]# cat bak.log 开始:2014年07月28日 19:02:59 结束:2014年07月28日 19:02:59 20140728.sql.tgz succ 开始:2014年07月28日 19:12:01 结束:2014年07月28日 19:12:01 20140728.sql.tgz succ [root@master full]#
增量备份:
[root@master leo]# cat DBDailyBak.sh #!/bin/bash BakDir=/root/leo/binlog/ BinDir=/var/lib/mysql LogFile=/root/leo/binlog/bak.log BinFile=/var/lib/mysql/mysql-bin.index mysqladmin -uroot -p123456 flush-logs Counter=`wc -l $BinFile|awk '{print $1}'` NextNum=0 for file in `cat $BinFile` do base=`basename $file` NextNum=`expr $NextNum + 1` if [ $NextNum -eq $Counter ] then echo $base skip! >> $LogFile else dest=$BakDir/$base if(test -e $dest) then echo $base exist! >> $LogFile else cp $BinDir/$base $BakDir/ echo $base copying >> $LogFile fi fi done echo `date +"%Y年%m月%d日 %H:%M:%S"` $Next Bakup succ~ >> $LogFile

本篇文章给大家带来了关于mysql的相关知识,其中主要介绍了关于架构原理的相关内容,MySQL Server架构自顶向下大致可以分网络连接层、服务层、存储引擎层和系统文件层,下面一起来看一下,希望对大家有帮助。

mysql的msi与zip版本的区别:1、zip包含的安装程序是一种主动安装,而msi包含的是被installer所用的安装文件以提交请求的方式安装;2、zip是一种数据压缩和文档存储的文件格式,msi是微软格式的安装包。

方法:1、利用right函数,语法为“update 表名 set 指定字段 = right(指定字段, length(指定字段)-1)...”;2、利用substring函数,语法为“select substring(指定字段,2)..”。

在mysql中,可以利用char()和REPLACE()函数来替换换行符;REPLACE()函数可以用新字符串替换列中的换行符,而换行符可使用“char(13)”来表示,语法为“replace(字段名,char(13),'新字符串') ”。

转换方法:1、利用cast函数,语法“select * from 表名 order by cast(字段名 as SIGNED)”;2、利用“select * from 表名 order by CONVERT(字段名,SIGNED)”语句。

本篇文章给大家带来了关于mysql的相关知识,其中主要介绍了关于MySQL复制技术的相关问题,包括了异步复制、半同步复制等等内容,下面一起来看一下,希望对大家有帮助。

在mysql中,可以利用REGEXP运算符判断数据是否是数字类型,语法为“String REGEXP '[^0-9.]'”;该运算符是正则表达式的缩写,若数据字符中含有数字时,返回的结果是true,反之返回的结果是false。

本篇文章给大家带来了关于mysql的相关知识,其中主要介绍了mysql高级篇的一些问题,包括了索引是什么、索引底层实现等等问题,下面一起来看一下,希望对大家有帮助。


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Dreamweaver CS6
Visual web development tools

WebStorm Mac version
Useful JavaScript development tools

Zend Studio 13.0.1
Powerful PHP integrated development environment

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.