易截截图软件、单文件、免安装、纯绿色、仅160KB

用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中的一个难题

昨天,我突然想把一个数据库里的每个表,以及每个表的非空总纪录数存在另一个表里面。
首先,创建了一个存放数据的表:
create table tables
(
name varchar(50),
number int
);
insert into tables select table_name from information_schema.tables where table_shema = 'test';
但是不知道有没有方法,将非空的 ......

常用到的mysql命令笔记

mysql设置密码和修改密码:
/usr/local/mysql/bin/mysqladmin -uroot password 123456 第一次设密码。
mysqladmin -uroot -p password mypasswd 修改密码
输入这个命令后,需要输入root的原密码,然后root的密码将改为mypasswd。
就是mysql5导出的有default-charact的设置,mysql4不支持,需要加skip-opt参数,如:
my ......

更改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数据库的默认编码2

使用mysql 经常会遇到编码问题,而导致程序出现乱码,mysql 在以下几个地方会涉及到编码格式
数据库编码
服务器编码
连接编码
客户端编码
下面是一个典型的示例, 运行 mysql -u root
查看编码 mysql>status
mysql Ver 14.7 Distrib 4.1.14, for Win32 (ia32)
Connection id: 90
Current database: yitian ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号