MariaDB MD5() Function
Learn MariaDB MD5() syntax, its 32-character checksum result, NULL behavior, and why it is not suitable for passwords or encryption.
On this page
MariaDB MD5(str) calculates an MD5 checksum and returns it as a 32-character hexadecimal string. It returns NULL when str is NULL. See the official MD5() documentation.
Syntax
MD5(str)
Examples
Calculate a checksum for a string:
SELECT MD5('Hello World');
Result:
b10a8db164e0754105b7a99be72e3fe5MD5() accepts expressions as well as literals. This example calculates a checksum for each stored text value:
CREATE TEMPORARY TABLE text_assets (
asset_id INT PRIMARY KEY,
contents TEXT NOT NULL
);
INSERT INTO text_assets (asset_id, contents)
VALUES (1, 'Sample document'), (2, 'Another sample');
SELECT asset_id, MD5(contents) AS md5_checksum
FROM text_assets
ORDER BY asset_id;
A NULL input returns NULL:
SELECT MD5(NULL);
Security limits
MD5 is a fast, legacy checksum. It is not encryption, and its one-way output does not make it suitable for storing passwords. Do not use MD5 for password storage, digital signatures, or integrity checks where an attacker may deliberately alter the data. MariaDB recommends MD5 only for checking data integrity against unintentional corruption.
For application passwords, use a maintained password-hashing library such as Argon2id, bcrypt, or PBKDF2. For a SHA-2 family digest, see MariaDB SHA2(); a fast SHA-2 digest is also not a password-hashing algorithm. See the OWASP Password Storage Cheat Sheet.
Summary
Use MD5() only where a legacy or non-security checksum is required. It returns a 32-character hex digest, not encrypted text, and should not protect passwords or security-sensitive data.