Free MySQL Password Hash Generator — Create MySQL PASSWORD Hashes
CodexFuse Team · 2026-10-13T10:54:38.796Z · 6 min read min read
Generate MySQL PASSWORD hashes for test and migration work. Learn the classic format, the shell method, and the version traps that break logins.
A MySQL password hash is the scrambled string MySQL stores for a database user account. If you migrate a database, test a login, seed a development environment, or restore access to an old server, you need a hash in exactly the format MySQL expects. A hash that is one character off, or built with the wrong algorithm, will simply not authenticate.
This guide covers the classic format, the shell method, and the version traps that break logins. Work with test passwords only. Never paste a real password into any website. The MySQL format is a legacy account format, not secure protection for real passwords. For new applications, use bcrypt or Argon2id.
What Is a MySQL Password Hash?
A MySQL password hash is a one-way scrambled version of a password, produced by hashing the password twice with SHA-1 and storing the result as a 41-character string that starts with an asterisk. When you log in, MySQL hashes the typed password and compares it with the stored value.
The asterisk is a marker. The remaining 40 characters are uppercase hexadecimal, the SHA-1 digest of the SHA-1 digest of the password. A widely used test example is *2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19. One-way means the hash can verify a password but cannot be reversed into it.
That one-way property is the whole point.
How Does MySQL Store Account Passwords?
MySQL stores password hashes in the mysql.user system table, in the authentication_string column, next to a plugin column that records which authentication method produced the hash. The plugin matters as much as the hash, because MySQL uses it to decide which algorithm verifies a login.
What each column holds
- User and Host: the account identity. MySQL treats the same app name at different hosts as different accounts.
- plugin: the authentication plugin name. It decides which algorithm verifies the password.
- authentication_string: the password hash itself.
- password_expired and account_locked: flags that can block logins even with the correct password.
When you create a user, MySQL hashes the password with the server's default plugin and stores the result. When you generate a hash externally for a migration script or a seed file, you are reproducing that step by hand.
How Do You Generate a MySQL Password Hash Online?
Open a MySQL password hash generator, type the test password, and copy the 41-character hash it returns. The process takes under a minute, with no installation and no account. Use test passwords only, and never paste a real password into any website.
- Open the free MySQL password hash generator in your browser. No sign-up is needed.
- Type the test password exactly as the account will use it.
- Generate the hash and check that the result starts with an asterisk.
- Copy the full 41-character string. Omitting the asterisk is the most common copy error.
- Paste it into your migration script or seed file.
- Test the login with the test password before calling the job done.
Because the generator runs in your browser, the password you type is never transmitted or stored. Even so, keep production credentials out of browser tools entirely.
How Do You Generate a MySQL Password Hash in the MySQL Shell?
On MySQL 5.7 or earlier, run SELECT PASSWORD with your test password, which returns the classic 41-character hash directly. On MySQL 8.0, where PASSWORD no longer exists, create the user and read the stored hash back from the mysql.user table instead.
SELECT PASSWORD('correct-horse-battery-staple');CREATE USER 'app'@'%' IDENTIFIED WITH mysql_native_password BY 'correct-horse-battery-staple';SELECT user, host, plugin, authentication_string FROM mysql.user WHERE user = 'app';
You can also compute the same value in local code: SHA-1 applied twice, uppercased, with an asterisk in front.
What Changed Between MySQL 5.7 and MySQL 8?
MySQL 8 made caching_sha2_password the default authentication plugin, removed the PASSWORD function entirely, and deprecated the older mysql_native_password plugin. Together, these changes mean hashes generated the old way may not work on new servers without explicit configuration. Check the plugin column before you migrate any account.
| MySQL version | Default plugin | PASSWORD function |
|---|---|---|
| 5.7 | mysql_native_password | Deprecated |
| 8.0 | caching_sha2_password | Removed |
| 8.4 and later | caching_sha2_password | Removed |
The usual symptom is an application that connected fine to MySQL 5.7 and then fails against MySQL 8 with an authentication plugin error. The password did not change. The hash format expectation changed.
Is the MySQL PASSWORD Format Safe for New Applications?
No. The MySQL PASSWORD format is not safe for new applications, because its unsalted double-SHA-1 hash is fast to compute and therefore fast for an attacker to test guesses against. The function has also been removed from current MySQL versions. It remains useful only for maintaining compatibility with legacy MySQL accounts.
For any new application, store user passwords with a purpose-built algorithm in your application code: Argon2id, the current best practice; bcrypt, the widely supported standard; or scrypt, a solid choice when Argon2id libraries are unavailable.
If your application still hashes user passwords with MySQL functions, treat migration as a security task with a deadline. Re-hash at next login and store the new hash with a version marker. For that migration, the free Argon2 hash generator shows the modern format.
CodexFuse manages your databases for you: user accounts, password rotation, patching, backups, and monitoring, all on pay-as-you-go credits with no subscriptions and no lock-in.
Get Started with CodexFuseFrequently Asked Questions
What does a MySQL password hash look like?
A classic MySQL password hash is a 41-character string that starts with an asterisk, followed by 40 uppercase hexadecimal characters. The asterisk marks the MySQL 4.1 and later format, and the hex portion is the double-SHA-1 digest of the password.
Can I reverse a MySQL password hash to get the password back?
No. Hashing is one-way by design, so a MySQL password hash cannot be reversed into the original password. If a hash has been exposed, change the password instead of trying to recover it.
Why does PASSWORD not work on MySQL 8?
The PASSWORD function was removed in MySQL 8.0 as part of the move to the caching_sha2_password plugin. On MySQL 8, generate hashes with a generator or create the user and read the stored hash back.
What is the difference between mysql_native_password and caching_sha2_password?
mysql_native_password uses the classic unsalted double-SHA-1 hash and was the default through MySQL 5.7. caching_sha2_password uses salted SHA-256 with a server-side cache and has been the default since MySQL 8.0. A hash made for one will not verify under the other.
Should I use MySQL hashes for my application's user passwords?
No. MySQL account hashes exist for MySQL's own authentication system. Application user passwords should be hashed with Argon2id or bcrypt in your application code.
What Should You Do Next With Your MySQL Accounts?
Check the version, the plugin column, the hash length, and the lock status of every account you own, then test one login end to end. That short checklist resolves the majority of MySQL authentication failures without guessing. Fix the specific user or upgrade the specific client.
If an unknown hash turns up while auditing, identify it first with the free hash identifier. To see how keyed hashing protects the API calls in front of your database, read our HMAC-SHA256 generator guide.















