Bug #70473 "FROM_BASE64" Function Returns Hex Value
Submitted: 1 Oct 2013 4:13 Modified: 1 Oct 2013 8:36
Reporter: Fikri Fadzil Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:5.6.14 OS:Linux
Assigned to: CPU Architecture:Any
Tags: from_base64, UNHEX

[1 Oct 2013 4:13] Fikri Fadzil
Description:
"FROM_BASE64" function returns HEX value in MySQL 5.6.14 (upgraded from MySQL 5.5.2).

How to repeat:
Simply issue this query:
SELECT FROM_BASE64(TO_BASE64('MySQL'));
[1 Oct 2013 6:49] MySQL Verification Team
Hello Fikri,

Thank you for the report.
IMHO, this works as documented - http://dev.mysql.com/doc/refman/5.6/en/string-functions.html#function_from-base64

mysql> select version();
+-------------------------------------------+
| version()                                 |
+-------------------------------------------+
| 5.6.14-enterprise-commercial-advanced-log |
+-------------------------------------------+
1 row in set (0.00 sec)

mysql> SELECT TO_BASE64('MySQL'), FROM_BASE64(TO_BASE64('MySQL'));
+--------------------+---------------------------------+
| TO_BASE64('MySQL') | FROM_BASE64(TO_BASE64('MySQL')) |
+--------------------+---------------------------------+
| TXlTUUw=           | MySQL                           |
+--------------------+---------------------------------+
1 row in set (0.00 sec)

mysql> SELECT HEX('MySQL'),UNHEX(HEX('MySQL'));
+--------------+---------------------+
| HEX('MySQL') | UNHEX(HEX('MySQL')) |
+--------------+---------------------+
| 4D7953514C   | MySQL               |
+--------------+---------------------+
1 row in set (0.00 sec)

Could you please post what you are getting at your end & what you are expecting?

Thanks,
Umesh
[1 Oct 2013 7:12] Fikri Fadzil
Hi Umesh,

Thank you for your reply. I managed to get the same result as yours when I directly issue the query in MySQL console. The result that I received previously was coming from PHPMyAdmin instead of MySQL console.

I guess, the problem might came from misconfiguration in PHPMyAdmin.

I'm sorry for submitting this bug report. Thank you very much for your reply.

Regards,
Fikri Fadzil
[19 Nov 2021 9:54] Andrey Hristov
There is a comment in the MySQL Documentation regarding this function, which can be found here : https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_from-base64

"If FROM_BASE64() is invoked from within the mysql client, binary strings display using hexadecimal notation, depending on the value of the --binary-as-hex. For more information about that option, see Section 4.5.1, “mysql — The MySQL Command-Line Client”. "