Chinaunix首页 | 论坛 | 博客
  • 博客访问: 963227
  • 博文数量: 335
  • 博客积分: 10287
  • 博客等级: 上将
  • 技术积分: 3300
  • 用 户 组: 普通用户
  • 注册时间: 2005-08-08 15:29
文章分类

全部博文(335)

文章存档

2015年(4)

2014年(15)

2013年(17)

2012年(11)

2011年(12)

2010年(96)

2009年(27)

2008年(34)

2007年(43)

2006年(39)

2005年(37)

我的朋友

分类: Mysql/postgreSQL

2010-09-08 17:36:28

' 命令可以删除指定编号前的所有日志
  (3).用purge master logs to before 'YYYY-MM-DD HH24:MI:SS'命令可以删除'YYYY-MM-DD HH24:MI:SS'之前的产生的所有日志
  (4).可以在my.cnf中指定--expire_logs_days=#,此参数设置了binlog日志的过期天数
  4.测试案例
  [mysql@test2]$ mysql -uroot -p
  Enter password:
  Welcome to the MySQL monitor. Commands end with ; or g.
  Your MySQL connection id is 18 to server version: 5.0.26-standard-log
  Type 'help;' or 'h' for help. Type 'c' to clear the buffer.
  mysql> use test;
  Database changed
  mysql> select * from pet;
  +----------+--------+---------+------+------------+------------+
  | name | owner | species | sex | birth | death |
  +----------+--------+---------+------+------------+------------+
  | Fluffy | Harold | cat | f | 1993-02-04 | NULL |
  | Claws | Gwen | cat | m | 1994-03-17 | NULL |
  | Buffy | Harold | dog | f | 1989-05-13 | NULL |
  | Fang | Benny | dog | m | 1990-08-27 | NULL |
  | Bowser | Diane | dog | m | 1979-08-31 | 1995-07-29 |
  | Chirpy | Gwen | bird | f | 1998-09-11 | NULL |
  | Whistler | Gwen | bird | NULL | 1997-12-09 | NULL |
  | Slim | Benny | snake | m | 1996-04-29 | NULL |
  +----------+--------+---------+------+------------+------------+
  8 rows in set (0.06 sec)
  mysql> insert into pet values('hunter','yxyup','cat','f','1996-04-29',null);
  Query OK, 1 row affected (0.03 sec)
  mysql> select * from pet;
  +----------+--------+---------+------+------------+------------+
  | name | owner | species | sex | birth | death |
  +----------+--------+---------+------+------------+------------+
  | Fluffy | Harold | cat | f | 1993-02-04 | NULL |
  | Claws | Gwen | cat | m | 1994-03-17 | NULL |
  | Buffy | Harold | dog | f | 1989-05-13 | NULL |
  | Fang | Benny | dog | m | 1990-08-27 | NULL |
  | Bowser | Diane | dog | m | 1979-08-31 | 1995-07-29 |
  | Chirpy | Gwen | bird | f | 1998-09-11 | NULL |
  | Whistler | Gwen | bird | NULL | 1997-12-09 | NULL |
  | Slim | Benny | snake | m | 1996-04-29 | NULL |
  | hunter | yxyup | cat | f | 1996-04-29 | NULL |
  +----------+--------+---------+------+------------+------------+
  9 rows in set (0.00 sec)
mysql> update pet set sex='m' where name='hunter';
  Query OK, 1 row affected (0.00 sec)
  Rows matched: 1 Changed: 1 Warnings: 0
  mysql> delete from pet where name='hunter';
  Query OK, 1 row affected (0.00 sec)
  [mysql@test2]$ mysqlbinlog log-bin.000002
  /*!40019 SET @@session.max_insert_delayed_threads=0*/;
  /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
  # at 4
  #080313 7:52:47 server id 1 end_log_pos 98 Start: binlog v 4, server v 5.0.26-standard-log created 080313 7:52:47
  # Warning: this binlog was not closed properly. Most probably mysqld crashed writing it.
  # at 98
  #080313 10:06:26 server id 1 end_log_pos 229 Query thread_id=18 exec_time=0 error_code=0
  use test;
  SET TIMESTAMP=1205373986;
  SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1;
  SET @@session.sql_mode=0;
  /*!C latin1 */;
  SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8;
  insert into pet values('hunter','yxyup','cat','f','1996-04-29',null);
  # at 229
  #080313 10:07:13 server id 1 end_log_pos 334 Query thread_id=18 exec_time=0 error_code=0
  SET TIMESTAMP=1205374033;
  update pet set sex='m' where name='hunter';
  # at 334
  #080313 10:07:38 server id 1 end_log_pos 432 Query thread_id=18 exec_time=0 error_code=0
  SET TIMESTAMP=1205374058;
  delete from pet where name='hunter';
  # at 432
  #080313 10:14:13 server id 1 end_log_pos 532 Query thread_id=18 exec_time=0 error_code=0
  SET TIMESTAMP=1205374453;
  create table t1(id int,name char(10));
  # at 532
  #080313 10:14:41 server id 1 end_log_pos 625 Query thread_id=18 exec_time=0 error_code=0
  SET TIMESTAMP=1205374481;
  alter table t1 add sex char(2);
  # End of log file
  ROLLBACK /* added by mysqlbinlog */;
  /*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
  [mysql@test2]$
  可以看出,三条DML操作和两条DDL都记录到了binlog中了,而select并没有记录。
阅读(751) | 评论(0) | 转发(1) |
给主人留下些什么吧!~~