10203

MD5(RAND()) on MySQL returning only digits

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.

Answer1:

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.

Answer2:

The MySQL documentation does suggest that the result should be a string or NULL no matter what. At a guess, could this be happening because the argument to MD5() is a number? What happens if you use SELECT MD5(CONCAT(RAND(), ''))?

Recommend

  • create function throws error in mysql,can someone help me out?
  • wp-admin can't access after moving
  • Restoring deleted mysql database
  • How to change the base_url in magento.,because my site were gone after i'm changing that on my
  • Encoding: everything is UTF-8 but the DB output is displayed wrong. Any Ideas?
  • Invoking a controller's action by button in View without redirecting to any view
  • Play Framework The type … is already defined
  • Find longest path less than or equal to given value of an acyclic, directed graph in Python
  • Receive mouse move even cursor is outside control
  • How to autopopulate a field in SugarCRM form
  • Updating both a ConcurrentHashMap and an AtomicInteger safely
  • Differences in dis-assembled C code of GCC and Borland?
  • Xcode 4 NSLog Macro link in Xcode 3
  • Meteor: Do Something On Email Verification Confirmation
  • Get one-time binding to work for ng-if
  • Is there any way to access browser form field suggestions from JavaScript?
  • Jenkins: How To Build multiple projects from a TFS repository?
  • How do I fake an specific browser client when using Java's Net library?
  • Possible to stop flickering java tooltip in heavyweight mode?
  • Where to put my custom functions in Wordpress?
  • sending/ receiving email in Java
  • How to set my toolbar fixed while scrolling android
  • Apache 2.4 - remove | delete | uninstall
  • RestKit - RKRequestDelegate does not exist
  • AT Commands to Send SMS not working in Windows 8.1
  • Run Powershell script from inside other Powershell script with dynamic redirection to file
  • Windows forms listbox.selecteditem displaying “System.Data.DataRowView” instead of actual value
  • WPF Applying a trigger on binding failure
  • File not found error Google Drive API
  • Qt: Run a script BEFORE make
  • apache spark aggregate function using min value
  • Django query for large number of relationships
  • Sorting a 2D array using the second column C++
  • Why is Django giving me: 'first_name' is an invalid keyword argument for this function?
  • Binding checkboxes to object values in AngularJs
  • How can I use `wmic` in a Windows PE script?
  • Net Present Value in Excel for Grouped Recurring CF
  • How to push additional view controllers onto NavigationController but keep the TabBar?
  • jQuery Masonry / Isotope and fluid images: Momentary overlap on window resize
  • How to load view controller without button in storyboard?