首页 > 代码库 > mysql 中用户默认密码加密问题
mysql 中用户默认密码加密问题
问题描述:
在mysql中 user表中新增用户默认密码为123456,但是在数据库中显示不能为明文,而mysql的默认字段不能用函数
解决方法:
用触发器
delimiter |
drop trigger if exists default_user_pwd;
create trigger default_user_pwd before insert on user
for each row
if (new.pwd is null or new.pwd =‘‘ or new.pwd =‘123456‘ )then
set new.pwd = ENCODE(‘123456‘,‘password‘);
end if;|
使用范围
可以检测某些值是否null 或者为空
mysql 中用户默认密码加密问题
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。