用MySQL 生成随机密码-增加大写处理
2012-05-30 14:02
253 查看
以前写过:
http://blog.chinaunix.net/uid-259788-id-2139370.html
这次增加了大写字母的处理。
调用方法类似。
http://blog.chinaunix.net/uid-259788-id-2139370.html
这次增加了大写字母的处理。
DELIMITER $$ USE `t_girl`$$ DROP FUNCTION IF EXISTS `func_rand_string`$$ CREATE DEFINER=`root`@`localhost` FUNCTION `func_rand_string`(f_num TINYINT UNSIGNED,f_type TINYINT UNSIGNED) RETURNS VARCHAR(32) CHARSET utf8 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(65+32*(CEIL(RAND()*2)-1)+CEIL(RAND()*25))); ELSEIF f_type=2 THEN SET v_result = CONCAT(v_result,CEIL(RAND()*9)); ELSEIF f_type=3 THEN IF (CEIL(RAND()*2)-1) = 1 THEN SET v_result = CONCAT(v_result,SUBSTRING(REPLACE(UUID(),'-',''),i+1,1)); ELSE SET v_result = CONCAT(v_result,UPPER(SUBSTRING(REPLACE(UUID(),'-',''),i+1,1))); END IF; END IF; SET i = i + 1; END WHILE; RETURN v_result; END$$ DELIMITER ;
调用方法类似。
相关文章推荐
- 用MySQL 生成随机密码-增加大写处理
- 【原创】用MySQL 生成随机密码-增加大写处理
- mysql获取某个范围内的随机数,写了个存储过程自动生成随机6为密码
- 在MySQL中生成随机密码的方法
- mysql 随机生成密码
- Linux系统下以RPM方式安装mysql-5.7.9【5.7版本以后,启动mysqld服务首次登录需要密码,为root生成的随机密码在错误日志文件/var/log/mysqld.log】
- 【原创】MySQL 生成随机密码
- 在 MySQL 中根据规则生成随机密码
- MySQL 生成随机密码
- 在MySQL中生成随机密码的方法
- 【原创】MySQL 生成随机密码
- MySQL 中根据规则生成随机密码
- MySQL 生成随机密码 笔记
- 随机生成长度为len的密码,且包括大写、小写英文字母和数字
- MySQL 生成随机密码
- 用MySQL 生成随机密码
- 随机生成长度为len的密码,且包括大写、小写英文字母和数字
- 用MySQL 生成随机密码
- mysql5.7默认生成随机密码,不知道登录时需要强改
- 随机生成密码脚本