mysql 中用户默认密码加密问题
2017-06-08 11:33
399 查看
问题描述:
在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 或者为空
补充:
由于encode 和decode 在使用中会生成空白字符串的问题
改用base64
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 = to_base64('123456');
end if;|
在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 或者为空
补充:
由于encode 和decode 在使用中会生成空白字符串的问题
改用base64
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 = to_base64('123456');
end if;|
相关文章推荐
- MySQL 5.7以上 root用户默认密码问题【转】
- MySQL 5.7以上 root用户默认密码问题
- 给mysql默认root用户设置密码
- MySql安装root用户密码设置失败问题解决
- 给mysql默认root用户设置密码
- mysql_config_editor 加密用户的密码
- ubuntu默认root密码问题,Ubuntu切换超级用户
- 关于忘记MySQL的root用户密码的问题
- 给mysql默认root用户设置密码
- MySQL修改root用户密码引起的root超级权限丢失的问题(Mac平台
- 给mysql默认root用户设置密码
- 重置mysql Root用户密码及修改默认字符集一般就算设置了表的默认字符集为utf8并且通过UTF-8编码发送查询,你会发现存入数据库的仍然是乱码。问题就出在这个connection连接层上。 解决
- mysql 用户登录密码和远程登录权限问题
- 给mysql默认root用户设置密码
- Oracle Sys用户用默认密码change_on_install 无法登录的问题(错误代码:ORA-28009)
- 给mysql默认root用户设置密码
- 如何在mysql中修改md5加密过的用户密码
- 给mysql默认root用户设置密码
- MySQL5.6之后默认root密码的问题
- 用户登录时的用户名密码加密解密问题和“记住密码”功能