自己做的网站如何让百度搜索,网页设计制作要求,做公众号的公司是什么公司,重庆建设工程招标信息网站一.概述由于服务器生成的二进制日志文件以二进制格式保存#xff0c;所以如果要想检查这些文件的文本格式#xff0c;就会用到mysqlbinlog日志管理工具。mysqlbinlog的语法如下:mysqlbinlog [options] log-files log-files2...其中options有很多选项#xff0c;常用如下所以如果要想检查这些文件的文本格式就会用到mysqlbinlog日志管理工具。mysqlbinlog的语法如下:mysqlbinlog [options] log-files log-files2...其中options有很多选项常用如下选项说明-d, --databasename指定数据库名称只列出指定的数据库相关操作。-o, --offset#忽略掉日志中的前n行命令-r, --result-filename将输出的文本格式日志输出到指定文件-s,--short-form显示简单格式省略掉一些信息--set--charsetchar-name在输出为文本格式时在文件第一行加上set names char-name.-- start-datetimename-stop-datetimename指定日期间隔内的所有日志--start-position# --stop-position#指定位置间隔内的所有日志1.1 开启binlog日志默认情况下是未打开binlog日志可以通过以下二种方式查看mysql show binarylogs;ERROR1381 (HY000): You are not using binarylogging--或者这样查看mysql show variables like %log_bin%开启binlog日志修改my.cnf文件重启mysql服务如下所示再次查询binlog日志状态二. 使用mysqlbinlog查看日志--先在test表中插入一条数据退出。mysql insert into a values(testbinlog);--查看binlog位置[roothsr mysql]# cd/var/lib/mysql[roothsr mysql]#lsmysql-bin.000001 mysql-bin.index2.1 使用mysqlbinlog查看日志 不加任何options参数[roothsr~]# cd /usr/local/mysql/bin[roothsr bin]# ./mysqlbinlog /var/lib/mysql/mysql-bin.000001上面的日志文件除了创建表和删除表的sql外操作数据库的语句都加密了。2.2 使用参数--base64-outputdecode-row -v查看具体的sql语句如下命令[roothsr bin]# ./mysqlbinlog --base64-outputdecode-row -v /var/lib/mysql/mysql-bin.000001上图中 at 291是插入语句的开始位置 at 384是插入语句的结束位置。如果后续该表数据丢失可以根据这两个地方执行恢复。也可以根据开始时间和结束时间来恢复后面再讲日志时具体介绍。2.3 加-d选项将只显示对test数据库的操作日志[roothsr bin]# ./mysqlbinlog /var/lib/mysql/mysql-bin.000001 -d test2.4 加-o选项, 忽略掉日志中的前n个操作。演示下--插入三条数据INSERT INTO a VALUES(testbinlog2)INSERT INTO a VALUES(testbinlog3)INSERT INTO a VALUES(testbinlog4)[roothsr bin]# ./mysqlbinlog --base64-outputdecode-row -v /var/lib/mysql/mysql-bin.000001 -d test -o 14上图显示日志生成后从at 898行开始显示。 14个操作代表日志显示跳过14个at。2.5 加-r选项将输出的文本格式日志输出到指定文件下面将文件结果输出到文件resultfile中。[roothsr bin]# ./mysqlbinlog --base64-outputdecode-row -v /var/lib/mysql/mysql-bin.000001 -r resultfile[roothsr bin]#more resultfile2.6 加-s 将内容进行简单显示[roothsr bin]# ./mysqlbinlog --base64-outputdecode-row -v /var/lib/mysql/mysql-bin.000001 -s如上图所示简单显示后没有了详细的sql语句。2.7 加--start-datetime--stop-datetime显示9:00 ~12:00之间的日志[roothsr bin]# ./mysqlbinlog --base64-outputdecode-row -v /var/lib/mysql/mysql-bin.000001--start-datetime2018/08/30 09:00:00 --stop-datetime2018/08/30 12:00:00如上图所示最后显示的时间截是1535600091, 转换后是2018-08-30 11:34:51。 开始和结束日期可以只写一个。2.8 加--start-position#和--stop-position# 和日期范围类似不过更精确[roothsr bin]# ./mysqlbinlog --base64-outputdecode-row -v /var/lib/mysql/mysql-bin.000001 --start-position944