-- =============== 测试md5 加密 =======================
CREATE TABLE `testmd5`(
`id` INT(4) NOT NULL,
`name` VARCHAR(20) NOT NULL,
`pdw` VARCHAR(50) NOT NULL,
PRIMARY KEY(`id`)
)ENGINE=INNODB DEFAULT CHARSET=utf8
-- 明文密码
INSERT INTO testmd5 VALUES(1,'张三','123456'),(2,'李四','123456'),(3,'王五','123456')
-- 加密
UPDATE testmd5 SET pdw=MD5(pdw) WHERE id = 1
UPDATE testmd5 SET pdw=MD5(pdw) -- 加密全部
-- 插入的时候加密
INSERT INTO testmd5 VALUES(6,'小菜',MD5('123456')),(7,'小栗子',MD5('123456'))
-- 如何校验: 将用户的密码md5 加密
SELECT * FROM testmd5 WHERE `name`='张三' AND pdw=MD5('123456')