SQL过程密码通配符检查不起作用

时间:2019-02-14 14:48:06

标签: mysql sql

我有一个过程可以确保密码至少包含1个数字,1个小写/大写字母和8个字符长。唯一有效的方法是长度检查,但我的通配符检查不起作用

CREATE DEFINER=`root`@`localhost` PROCEDURE `password_validation`(IN user_password varchar(255), IN password_confirmation varchar(255), OUT Valid bool, OUT description varchar(255))
BEGIN
IF (user_password != password_confirmation) then
    set Valid = false;
    set Description = 'Passwords do not match';
ELSEIF (user_password Like '%[0-9]%' And user_password Like'%[a-zA-Z]%' And LENGTH(user_password) >= 8 ) then
    set Valid = true;
    set Description = 'Valid Password';
ELSE
    set Valid = false;
    set Description = 'Password must be at least 8 characters, have at least 1 upper case and at least 1 number';
END IF;
END

0 个答案:

没有答案