mysql儲存登入 MYSQL儲存過程實現使用者登入

2021-10-17 21:41:55 字數 1696 閱讀 2974

create definer=`root`@`%` function`uc_session_login`(

`re**son` json,

`srvjson` json

)returnsjson

language sqlnotdeterministiccontainssql

sql security definer

comment'uc的使用者登入,返回json'

begin#呼叫例子

#金鑰表declare _keyid int(10)unsigned;declare _secretkey char(32);

#登入表declare _uid int(10)unsigned;declare _username varchar(50);declare _password char(32);declare _salt char(6);

#位址記錄表declare _failedlogins int(10)unsigned;declare _resetwhen timestamp;#計次重置時間

#與字段無關的輸入declare failedlogins_max int(10)unsigned default 3;#密碼錯誤次數上限declare failedlogins_timeout int(10)unsigned default 20;#時間範圍內清零計數declare failedlogins_unlocktime int(10)unsigned default 10;#密碼錯誤次數超限後鎖定時間

#與字段無關的輸出declare userjson json defaultjson_object();

#首先判斷ip位址是否已被禁止嘗試密碼

#delete from uc_session_ipaddress where resetwhen=failedlogins_max then

elseif _failedlogins=0 then#記錄第一次密碼錯誤,並設定新的計數超時時間update uc_session_ipaddress set failed=current_timestamp(),failedlogins=@cu***iled,faileduid=_uid,resetwhen=@resetwhen_timeout where ipaddress=useripaddress;else

update uc_session_ipaddress set failed=current_timestamp(),failedlogins=@cu***iled,faileduid=_uid,resetwhen=timestampadd(second,failedlogins_unlocktime,current_timestamp()) where ipaddress=useripaddress;end if;if @cu***iled>=failedlogins_max then

return json_set(retjson,'$.errno',-3,'$.message',concat('由於密碼錯誤次數已達',failedlogins_max,'次,現已被鎖定',failedlogins_unlocktime,'秒'));end if;return json_set(retjson,'$.errno',-2,'$.message',concat('您已輸錯',@cu***iled,'次密碼,如再錯',failedlogins_max-@cu***iled,'次將被鎖定',failedlogins_unlocktime,'秒'));end if;

#登入校驗已通過

mysql儲存nosql NoSQL常見儲存方式

一 鍵值儲存 它的資料是以鍵值的形式儲存的,雖然它的速度非常快,但基本上只能通過鍵的完全一致查詢獲取資料,根據資料的儲存方式可以分為臨時性 永久性和兩者兼具三種。1 臨時性 memcached 所謂臨時性就是資料有可能丟失,memcached把所有資料都儲存 一 鍵值儲存 它的資料是以鍵值的形式儲存...

mysql的儲存過程初識 初識MySQL儲存過程

儲存過程 stored procedure 是一組為了完成特定功能的sql語句集,經編譯後儲存在資料庫中,使用者通過指定儲存過程的名字並給定引數 如果該儲存過程帶有引數 來呼叫執行它。mysql 儲存過程是從mysql 5.0開始增加的新功能。大大提高資料庫的處理速度,同時也可以提高資料庫程式設計的...

mysql儲存登入 MySQL資料庫登入與常用命令

第一招 mysql服務的啟動和停止 net stop mysql net start mysql 第二招 登陸mysql 語法如下 mysql u使用者名稱 p使用者密碼 鍵入命令mysql uroot p,回車後提示你輸入密碼,輸入12345,然後回車即可進入到mysql中了,mysql的提示符是...