mysql-bin.000001

今天发现/usr/local/mysql/var下很多mysql-bin.000001、mysql-bin.000002文件,GOOGLE之。。这是数据库的操作日志,例如UPDATE一个表,或者DELETE一些数据,即使该语句没有匹配的数据,这个命令也会存储到日志文件中,还包括每个语句执行的时间,也会记录进去的。这样做主要有以下两个目的:
1:数据恢复
如果你的数据库出问题了,而你之前有过备份,那么可以看日志文件,找出是哪个命令导致你的数据库出问题了,想办法挽回损失。
2:主从服务器之间同步数据
主服务器上所有的操作都在记录日志中,从服务器可以根据该日志来进行,以确保两个同步。处理方法分两种情况:
1:只有一个mysql服务器,那么可以简单的注释掉这个选项就行了。
vi /etc/my.cnf把里面的log-bin这一行注释掉,重启mysql服务即可。
2:如果你的环境是主从服务器,那么就需要做以下操作了。
A:在每个从属服务器上,使用SHOW SLAVE STATUS来检查它正在读取哪个日志。
B:使用SHOW MASTER LOGS获得主服务器上的一系列日志。
C:在所有的从属服务器中判定最早的日志,这个是目标日志,如果所有的从属服务器是更新的,就是清单上的最后一个日志。
D:清理所有的日志,但是不包括目标日志,因为从服务器还要跟它同步。
清理日志方法为:
PURGE MASTER LOGS TO ‘mysql-bin.010‘;
Query OK, 0 rows affected (8.51 sec)mysql>好了,我们再来查看下mysql文件夹占用多少空间?[[email protected] var]# du -h –max-depth=1 /usr/local/mysql/
37M /usr/local/mysql/var
70M /usr/local/mysql/mysql-test
15M /usr/local/mysql/lib
448K /usr/local/mysql/include
2.9M /usr/local/mysql/share
7.6M /usr/local/mysql/libexec
17M /usr/local/mysql/bin
11M /usr/local/mysql/docs
2.9M /usr/local/mysql/sql-bench
163M /usr/local/mysql/好了,看一下,整个mysql 目录才占用163M大小!OK,没问题,既然mysql-bin.0000X日志文件占用这么大空间,存在的意义又不是特别大,那么我们就不让它生成吧.

[[email protected] var]# find / -name my.cnf 找到了my.cnf 即mysql配置文件,我们将log-bin=mysql-bin 这条注释掉即可.

# Replication Master Server (default)

mysql-bin.000001,布布扣,bubuko.com

时间: 2024-11-12 18:47:52

mysql-bin.000001的相关文章

mysqlbinlog 查看mysql bin 日志 mysqlbinlog: unknown variable 'default-character-set=utf8'

mysqlbinlog  mysql-bin.000036 | less 查询包含几个字段的语句: mysqlbinlog mysql-bin.000036| egrep '(2011030610002460|2011030310001730|2011030410011680|2011030410006280)' mysqlbinlog查看二进制日志的问题 在使用mysqlbinlog查看日志的时候碰到了一个问题, 错误提示如下:/usr/local/mysql/bin/mysqlbinlog:

mysql bin日志配置及查看

mysql执行sql可以通过设置mysql bin 日志进行记录查看,mysql bin日志配置如下: log_bin:on log_bin_basename:bin文件路径及名前缀(/var/log/mysql/mysql-bin) log_bin_index:bin文件index(/var/log/mysql/mysql-bin.index) server_id:n 生成的bin日志如:mysql-bin.000000  mysql-bin.000001 通过mysqlbinlog mysq

sql命令查看,清楚mysql bin日志

查看二进制日志文件 mysql> SHOW BINLOG EVENTS \G; mysql> SHOW MASTER LOGS; 清除二进制日志文件 mysql> PURGE { MASTER|BINARY } LOGS TO 'log_name'; mysql> PURGE { MASTER|BINARY } LOGS BEFORE 'datetime'; 例如: mysql> PURGE MASTER LOGS TO 'mysql-bin.000001'; mysql&g

[mysqldumpslow 报错] Died at /usr/local/mysql/bin/mysqldumpslow line 161, <> chunk 236.

mysqldumpslow报错:Died at /usr/local/mysql/bin/mysqldumpslow line 161, <> chunk 236. 总结:是因为top数目太多了,mysqldumpslow遍历不过来的缘故. /usr/local/mysql/bin/mysqldumpslow -s -t 15 /root/db01-102-slow.log 1,把r去掉试试,还是报错,参数不识别. [[email protected] ]# /usr/local/mysql/

WARNING: The host &#39;r6&#39; could not be looked up with /usr/local/mysql/bin/resolveip.

初始化MySQL数据库提示以下信息: # /usr/local/mysql/scripts/mysql_install_db > --defaults-file=/etc/my.cnf > --basedir=/usr/local/mysql > --datadir=/var/mysql/data > --user=mysql WARNING: The host 'r6' could not be looked up with /usr/local/mysql/bin/resolv

mysqld_safe启动报错 mysqld_safe The file /usr/local/mysql/bin/mysqld does not exist or is not executable

报错(如下),但是使用mysqld直接启动没有问题. 150718 00:03:38 mysqld_safe Logging to '/var/log/mysqld.log'. 150718 00:03:38 mysqld_safe The file /usr/local/mysql/bin/mysqld does not exist or is not executable. Please cd to the mysql installation directory and restart t

mysql 初始化报错 /usr/local/mysql/bin/mysqld:error while loading shared libraries :libaio.so.1

安装mysql在初始化的时候,出现/usr/local/mysql/bin/mysqld:error while loading shared libraries:libaio.so.1 :cannot open shared object file:NO such file or directory 解决方法: <P>type the following</P> <P>apt-get install libaio1 libaio-dev</P> <P

mysql数据库二进制初始化出现:170425 17:47:04 [ERROR] /application/mysql//bin/mysqld: unknown option &#39;--skip-locking&#39; 170425 17:47:04 [ERROR] Aborting 解决办法

[[email protected] mysql]# ./scripts/mysql_install_db --user=mysql --basedir=/application/mysql/ --datadir=/application/mysql/data/Installing MySQL system tables...170425 17:47:04 [ERROR] /application/mysql//bin/mysqld: unknown option '--skip-locking

/usr/local/mysql/bin/mysqlbinlog -vv /var/lib/bin/mysql-bin.000008 --base64-output=DECODE-ROWS --start-pos=307

/usr/local/mysql/bin/mysqlbinlog -vv /var/lib/bin/mysql-bin.000008 --base64-output=DECODE-ROWS  --start-pos=307 问题:这个究竟是什么意思 [[email protected] mysql]# /usr/local/mysql/bin/mysqlbinlog -vv /var/lib/bin/mysql-bin.000008 --base64-output=DECODE-ROWS --s

WARNING: The host &#39;db01&#39; could not be looked up with /data/mysql/bin/resolveip. This probably means that your libc libraries are not 100 % compatible with this binary MySQL version......

Linux系统安装MySQL,环境参数: 硬件配置:CPU: Xeon(R) CPU E5-2650 v4 @ 2.20GHz 8核内存:16G硬盘:系统盘200GB 数据盘1TB 操作系统CentOS 7.2 64位 数据库MySQL 5.6.43 执行scripts/mysql_install_db --user=mysql脚本报错: WARNING: The host 'db01' could not be looked up with /data/mysql/bin/resolveip.