ID EN
String Functions and Operators

TO_BASE64(str)

MySQL 8.4

Converts the string argument to base-64 encoded form and returns the result as a character string with the connection character set and collation. If the argument is not a string, it is converted to a string before conversion takes place. The result is NULL if the argument is NULL. Base-64 encoded strings can be decoded using the FROM_BASE64() function.

Syntax

MYSQL
SELECT TO_BASE64('abc'), FROM_BASE64(TO_BASE64('abc'));
'JWJj', 'abc'

Examples

Example

Different base-64 encoding schemes exist. These are the encoding and decoding rules used by TO_BASE64() and FROM_BASE64():

MYSQL
SELECT TO_BASE64('abc'), FROM_BASE64(TO_BASE64('abc'));
'JWJj', 'abc'