为此,您可以使用MD5()。让我们首先创建一个表-
mysql> create table DemoTable1887 ( Password text, HashPassword text );
使用插入命令在表中插入一些记录-
mysql> insert into DemoTable1887(Password) values('John@9089'); mysql> insert into DemoTable1887(Password) values('90987_Carol'); mysql> insert into DemoTable1887(Password) values('656464_David_4343');
使用插入命令在表中显示一些记录-
mysql> select * from DemoTable1887;
这将产生以下输出-
+-------------------+--------------+ | Password | HashPassword | +-------------------+--------------+ | John@9089 | NULL| | 90987_Carol | NULL| | 656464_David_4343 | NULL| +-------------------+--------------+ 3 rows in set (0.00 sec)
这是使用名称的md5版本更新所有条目的查询:
mysql> update DemoTable1887 set HashPassword=md5(Password); Rows matched: 3 Changed: 3 Warnings: 0
让我们再次检查表记录:
mysql> select * from DemoTable1887;
这将产生以下输出-
+-------------------+----------------------------------+ | Password | HashPassword | +-------------------+----------------------------------+ | John@9089 | 7f92a7e09ab1a0cd3f36ec164f035c9a | | 90987_Carol | 1578fa8c47f0e53a898c8ada5c0111b4 | | 656464_David_4343 | e5ec2bd2cb55b2252be7ca9eb546659e | +-------------------+----------------------------------+ 3 rows in set (0.00 sec)