用MySQL 生成随机密码
2009-09-12 00:05
405 查看
晚上有朋友问起,简单的写了一个。
调用方法示例:
select func_rand_string(12,3);
DELIMITER $$ CREATE FUNCTION `t_girl` . `func_rand_string` ( f_num tinyint unsigned , f_type tinyint unsigned ) RETURNS varchar ( 32) BEGIN -- Translate the number to letter. -- No 1 stands for string only. -- No 2 stands for number only. -- No 3 stands for combination of the above. declare i int unsigned default 0; declare v_result varchar ( 255) default '' ; while i < f_num do if f_type = 1 then set v_result = concat ( v_result, char ( 97+ ceil( rand ( ) * 25) ) ) ; elseif f_type= 2 then set v_result = concat ( v_result, char ( 48+ ceil( rand ( ) * 9) ) ) ; elseif f_type= 3 then set v_result = concat ( v_result, substring ( replace ( uuid ( ) , '-' , '' ) , i+ 1, 1) ) ; end if; set i = i + 1; end while; return v_result; END $ $ DELIMITER ;
调用方法示例:
select func_rand_string(12,3);
相关文章推荐
- Linux系统下以RPM方式安装mysql-5.7.9【5.7版本以后,启动mysqld服务首次登录需要密码,为root生成的随机密码在错误日志文件/var/log/mysqld.log】
- MySQL 生成随机密码 笔记
- 在 MySQL 中根据规则生成随机密码
- 在MySQL中生成随机密码的方法
- MySQL 生成随机密码
- 【原创】MySQL 生成随机密码
- 用MySQL 生成随机密码-增加大写处理
- 用MySQL 生成随机密码
- 用MySQL 生成随机密码-增加大写处理
- 在MySQL中生成随机密码的方法
- mysql 随机生成密码
- 【原创】用MySQL 生成随机密码-增加大写处理
- mysql5.7默认生成随机密码,不知道登录时需要强改
- MySQL 生成随机密码
- mysql获取某个范围内的随机数,写了个存储过程自动生成随机6为密码
- 【原创】MySQL 生成随机密码
- MySQL 中根据规则生成随机密码
- ASP生成随机密码的两个函数
- php生成随机密码的几种方法
- linux下生成随机密码的十种方法