基本信息
源码名称:MySQL随机生成登录验证码函数
源码大小:0.87KB
文件格式:.sql
开发语言:SQL
更新时间:2021-07-02
友情提示:(无需注册或充值,赞助后即可获取资源下载链接)
嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):78630559
本次赞助数额为: 2 元×
微信扫码支付:2 元
×
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
源码介绍
-- MySQL随机生成登录验证码函数
set global log_bin_trust_function_creators=on;
-- 解决1418错误 - This function has none of DETERMINISTIC, NO SQL, or READS SQL DATA in its declaration and binary logging is enabled (you *might* want to use the less safe log_bin_trust_function_creators variable)
delimiter $$
create function randVerificationCode(n int) returns varchar(255)
begin
-- 声明一个包含字母和数字的字符串str,共62个字符,
-- 其中包括26个字母大小写和0-9共10个数字。
declare str varchar(255) default 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
-- 声明一个变量i,记录当前字符的位置
declare i int default 0;
-- 声明返回字符串resStr
declare resStr varchar(255) default '';
while i < n do
set resStr=CONCAT(resStr,substr(str,floor(rand()*62 1),1));
set i=i 1;
end while;
return resStr;
end$$
delimiter ;
set global log_bin_trust_function_creators=off;
-- MySQL随机生成登录验证码函数
set global log_bin_trust_function_creators=on;
-- 解决1418错误 - This function has none of DETERMINISTIC, NO SQL, or READS SQL DATA in its declaration and binary logging is enabled (you *might* want to use the less safe log_bin_trust_function_creators variable)
delimiter $$
create function randVerificationCode(n int) returns varchar(255)
begin
-- 声明一个包含字母和数字的字符串str,共62个字符,
-- 其中包括26个字母大小写和0-9共10个数字。
declare str varchar(255) default 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
-- 声明一个变量i,记录当前字符的位置
declare i int default 0;
-- 声明返回字符串resStr
declare resStr varchar(255) default '';
while i < n do
set resStr=CONCAT(resStr,substr(str,floor(rand()*62 1),1));
set i=i 1;
end while;
return resStr;
end$$
delimiter ;
set global log_bin_trust_function_creators=off;