Linux mysql生成不了随机密码,用MySQL 生成随机密码
用MySQL 生成隨機密碼
晚上有朋友問起,簡單的寫了一個。
DELIMITER $$
CREATE
FUNCTION `t_girl`
.
`func_rand_string`
(
f_num tinyint
unsigned
,
f_type tinyint
unsigned
)
RETURNS varchar
(
32)
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
(
97+
ceil(
rand
(
)
*
25)
)
)
;
elseif f_type=
2 then
set
v_result =
concat
(
v_result,
char
(
48+
ceil(
rand
(
)
*
9)
)
)
;
elseif f_type=
3 then
set
v_result =
concat
(
v_result,
substring
(
replace
(
uuid
(
)
,
'-'
,
''
)
,
i+
1,
1)
)
;
end
if;
set
i =
i +
1;
end
while;
return v_result;
END
$
$
DELIMITER ;
調用方法示例:
select func_rand_string(12,3);
相關文檔:
啟動mysql:? /etc/rc.d/init.d/mysql start
修改密碼: 格式:mysqladmin -u用戶名 -p舊密碼 password 新密碼
使用密碼登錄:? mysql -u root -p
顯示數據庫:? show databases;
選擇數據庫:? use 數據庫名;
顯示表:? show tables;
顯示表結構:? descibe 表名;
遠程登錄mysql需要開啟� ......
一、設置數據庫編碼
安裝mysql時可選擇編碼,如果已經安裝過,可以更改文件my.ini(此文件在mysql的安裝目錄下)中的配制以達到目的;打開文件找到兩處:
[client]
port=3306
[mysql]
default-character-set=gb2312
# The default character set that will be used when a new
schema or table is
# created and
n ......
使用mysql 經常會遇到編碼問題,而導致程序出現亂碼,mysql 在以下幾個地方會涉及到編碼格式
數據庫編碼
服務器編碼
連接編碼
客戶端編碼
下面是一個典型的示例, 運行 mysql -u root
查看編碼 mysql>status
mysql Ver 14.7 Distrib 4.1.14, for Win32 (ia32)
Connection id: 90
Current database: yitian ......
9.3? MySQL存儲過程
MySQL 5.0以后的版本開始支持存儲過程,存儲過程具有一致性、高效性、安全性和體系結構等特點,本節將通過具體的實例講解PHP是如何操縱MySQL存儲過程的。
實例261:存儲過程的創建
這是一個創建存儲過程的實例
錄像位置:光盤\mingrisoft\09\261
實例說明
為了保證數據的完整性、一致性,提 ......
總結
以上是生活随笔為你收集整理的Linux mysql生成不了随机密码,用MySQL 生成随机密码的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: linux串口发送键值,c51:串口通信
- 下一篇: redis 一般启动几个 哨兵_Redi