mysql md5 返回数字,MySQL上的MD5(RAND())只返回数字

I'm running this sample code I found while googling:

SELECT MD5(RAND())

But, to my surprise, MD5 is returning plain digits, instead of hexadecimal digits.

Using CONV(MD5(RAND()), 10, 16) seems to solve my problem, but the MySQL documentation states that the MD5 function should return a string already in hexadecimal.

Am I doing something wrong?

EDIT2: This problem only appears to exist with phpMyAdmin, not the command-line version of MySQL.

EDIT: My MySQL version:

mysql --version

mysql Ver 14.14 Distrib 5.1.41, for debian-linux-gnu (x86_64) using readline 6.1

An example MD5 value:

6338666264663132376461666163313063656535633666616266396530613335

Also, CONV returns a very VERY short string, like:

B9

This string is often single-digit and the longest I got until now was 5 digits.

解决方案

Nevermind, I figured it out.

Somehow, phpMyAdmin is reading the result as binary.

There seems to be an option "Show binary contents as HEX" that's checked by default.

It appears that this "show as hex" option is causing the problems. Unchecking it seems to solve it.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值