标签 mysql 下的文章

1. 设置localhost的访问密码
$ mysqladmim -uroot -hlocalhost -p password '123456'
2. 设置已存在的用户的密码
mysql> set password for 'USERNAME'@'HOST'=password('password');
3. 设置已存在的用户的密码
mysql> update user set Password=password(password') where User='USERNAME' and Host='HOST';
4. 给远程用户设置密码
mysql> grant all privileges on *.* to 'root'@'192.168.31.%' identified by '123456';

mysql> flush privileges;

开启binlog,且binlog-format=row

新建一个表

[sql]CREATE TABLE student (id int(10) unsigned NOT NULL AUTO_INCREMENT,name varchar(10) NOT NULL DEFAULT '', class int(10), score varchar(10) NOT NULL DEFAULT '', PRIMARY KEY (id));[/sql]

插入测试数据:
insert into student(name,class,score) values('a',1,56),('b',1,61),('c',2,78),('d',2,45),('e',3,76),('f',3,89),('g',4,43),('h',4,90);
模拟update忘加where条件
update student set score='failure';
mysqlbinlog --no-defaults -v -v --base64-output=DECODE-ROWS bin-log.000039 | grep -B 15 'failure'

- 阅读剩余部分 -

开启binlog,且binlog-format=row

新建一个表
CREATE TABLE `student` (`id` int(10) unsigned NOT NULL AUTO_INCREMENT,`name` varchar(10) NOT NULL DEFAULT '',   `class` int(10), `score` varchar(10) NOT NULL DEFAULT '', PRIMARY KEY (`id`));
插入测试数据
insert into student(name,class,score) values('a',1,56),('b',1,61),('c',2,78),('d',2,45),('e',3,76),('f',3,89),('g',4,43),('h',4,90);
模拟删除
mysql> delete from student;
Query OK, 8 rows affected (0.00 sec)
 
mysql> select * from student;
Empty set (0.00 sec)

- 阅读剩余部分 -