MySQL generates a random password bitsCN.com
MySQL generates random passwords
I simplified the process, which is more concise than the previous one, and generally generates random passwords.
[SQL]
DELIMITER $
USE't _ girl $
Drop function if exists 'func _ range_string_mod '$
Create definer = 'root' @ 'localhost' FUNCTION 'func _ range_string_mod '(
F_num int unsigned -- Total strings.
) Returns varchar (200) CHARSET latin1
BEGIN
DECLARE I INT UNSIGNED DEFAULT 0;
DECLARE v_result VARCHAR (200) DEFAULT '';
DECLARE v_dict VARCHAR (200) DEFAULT '';
SET v_dict = 'abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz0123456789 ';
SET v_dict = LPAD (v_dict, 200, v_dict );
WHILE I <f_num
DO
SET v_result = CONCAT (v_result, SUBSTR (v_dict, CEIL (RAND () * 200), 1 ));
SET I = I + 1;
End while;
RETURN v_result;
END $
DELIMITER;
Call method:
Select func_range_string_mod (20); generate a password of 20 characters.
BitsCN.com