Free · runs in your browser

MySQL Password Hash Generator

MySQL Password Hash Generator. Enter a password to instantly get the exact hash MySQL's PASSWORD() function produces. Spotting tampering or a corrupted download is simple with the free md5 hash generator and a published digest to compare.

Your values

mysql_native_password gives the same hash every time. caching_sha2_password uses a new random salt on every Calculate, so the hash changes but every version works.

Hashed in your browser only. Spaces and a trailing newline change the hash.

'root'@'localhost' and 'root'@'%' are different accounts.

Result

Password hash
—
Password that was hashed
—
CREATE USER with the hash
—
ALTER USER with the hash
—
Change password on MySQL 5.7.6 and later (SQL)
—
Change password on MySQL 5.7.6 and later (console command)
—
Change password with mysql_native_password, MySQL 5.7.6 to 8.4 (SQL)
—
Change password with mysql_native_password, MySQL 5.7.6 to 8.4 (console command)
—
Change password on MySQL 5.7.5 and earlier (SQL)
—
Change password on MySQL 5.7.5 and earlier (console command)
—
Hash format
—
  • No account, no logging
  • Open formulas explained below
  • Works offline once loaded

Use this MySQL password hash generator to turn a plain password into the 41-character string the server actually stores. This free online tool works as a MySQL password hash creator for web developers, so you can paste the result into a statement without leaving a secret in your files, and it runs entirely in your browser.

Using the MySQL Password Hash Generator with CREATE USER

A MySQL hash generator does one narrow job. Type the password, press the button, and click copy to place the result on your clipboard. If you still need a random password, build one with crypto.getRandomValues or a trusted manager first, then generate MySQL password hashes from it. The hashing runs in JavaScript inside the page, so no request reaches a remote server.

Four-step flow showing the password Kestrel#4172-Lantern hashed twice with SHA1 into a 41-character MySQL password hash
The worked example from password to the stored 41-character value.
  1. Enter the password you want to protect.
  2. Choose the authentication plugin your account will use.
  3. Copy the generated hash.
  4. Paste it into the SQL your client sends to the server.

Because the output is a password hash rather than a secret, it is safe to keep in a deployment file, although you should still limit who can read that file. Each password you hash gets its own result, and hashing the same password again later returns the identical value, which makes the check repeatable. A note on security: the hash is only as strong as the original password, so weak input still produces a weak result.

Here is a worked example with a password made up for this page: Tr4ct0r-Lime-92!. The formula below produces *C83A5FDBFC81EC514E929A1C37E7A0E0D3CEF9B5, and you would send it as CREATE USER 'app_user'@'10.0.4.%' IDENTIFIED WITH mysql_native_password AS '*C83A5FDBFC81EC514E929A1C37E7A0E0D3CEF9B5'. Change one character to Tr4ct0r-Lime-93! and the output becomes *6DA9CC3AA35E722E59D4316B0083B76418384B46, which shares nothing with the first.

$$\text{hash} = \texttt{*} + \text{UPPER}\big(\text{HEX}\big(\text{SHA1}(\text{SHA1}(\text{password}))\big)\big)$$

Using the MySQL Password Hash Generator with CREATE USER
MethodStored valueLengthStatus
Pre-4.1 OLD_PASSWORD()16 hexadecimal characters16 bytesGone since 5.7.5
mysql_native_passwordStar plus 40 hex digits41 bytesDeprecated in 8.0.34
caching_sha2_passwordSalted SHA-256 digestLonger, binaryDefault on 8.0

The PASSWORD() Function and Double SHA1

The PASSWORD() function is a one-way function: it applies a cryptographic algorithm to the text twice, writes the digest as hexadecimal in uppercase and puts a star in front. That gives a 41-byte hash, and the hash value cannot be turned back into the original. The server compares what a client presents against this stored result at login, and the same input always yields the same output.

Is an Online MySQL Password Hash Generator Safe?

A client-side MySQL password generator built for programmers is only as private as its code, and this one hashes the text you type rather than inventing a new secret. Your plain text password is never sent anywhere, so the cleartext stays on your machine and the plaintext never lands in a request log. For experiments, hash a throwaway value and keep real credentials out of the page.

Cross-Browser Testing and Test Cases for Your Hash

Teams use a hash verifier during cross-browser testing of login forms, and the same habit works for MySQL: keep a known password and its expected star-prefixed hash as a fixture, then write test cases that compare it with the generator's output or with the result of a SELECT run in a scratch container. Commit those fixtures to Git next to your provisioning scripts so every environment starts with identical accounts.

The MySQL Hash Behind mysql_native_password

The MySQL hash you generate belongs to the mysql_native_password authentication plugin. When a client connects, the server hashes the password it receives and compares the result with the value stored for that account. The default plugin decides how that check works, each database account holds exactly one hash, and the server never keeps the original text. When editing an existing account row, note the user_login you are changing before you generate a wordpress password hash so the update statement hits the right row.

During login the client sends its password through the handshake, and the server hashes it and checks the result against the stored password hash. The host the client connects from also matters, since MySQL matches the user and host together before it compares any hash. That is why a correct password can still fail from the wrong host, and why a pre-4.1 value or a mismatched plugin gives an authentication error even when the text is right.

MySQL 5.7, MySQL 8.0 and MySQL 9.0 Authentication Plugin Support

The pre-4.1 format used a 16-byte value, and support for it was removed in MySQL 5.7.5 together with the OLD_PASSWORD() function, so any pre-4.1 hash in an old dump must be regenerated in the current format. The 4.1 format kept working, and mysql_native_password was deprecated in 8.0.34, switched off by default in 8.4 and finally dropped in MySQL 9.0. Check the version of your server before choosing a plugin, because compatibility depends on it.

Timeline of MySQL password hash formats from the 16-byte pre-4.1 hash to removal of mysql_native_password in MySQL 9.0
How MySQL password hashing changed from the pre-4.1 format to MySQL 9.0.

caching_sha2_password and Legacy Applications

Since version 8.0 the default plugin is caching_sha2_password, which stores a salted SHA-256 digest and may demand TLS or an RSA key on the first login. Legacy applications, older connectors and drivers keep working with mysql_native_password, so a migration plan should list every driver before you switch. MariaDB follows its own scheme, so a hash from this page may not carry over.

The User Table and the 41-Byte Hash

MySQL lists every account in the user table of its system schema and stores only the hash, never the password. Privileges follow the account, and a pre-4.1 value in that column is shorter and never starts with a star. The older design has no random salt, so identical passwords produce identical hashes, one more reason to retire it.

Seeding a Staging Database with a MySQL Password Hash

Priya Nair maintains a Docker Compose stack for a staging database, and her team's rule is that no plaintext password may appear in Git. She needs a read-only reporting account in init.sql, so she opens the MySQL password hash creator, types Harbor#Quill-4471, selects mysql_native_password and copies *4491FC867FDA4612FC315CB3044ABA4D4D1ABD91. The tool applies the formula from earlier, double SHA1, then uppercase hex with a star, which gives the expected 41 characters.

Her statement reads CREATE USER 'report_ro'@'10.0.4.%' IDENTIFIED WITH mysql_native_password AS '*4491FC86...ABD91', followed by a GRANT SELECT. Before committing, she cross-checks by running SELECT CONCAT('*', UPPER(SHA1(UNHEX(SHA1('Harbor#Quill-4471'))))) in a scratch container, and both values match.

Next comes a sensitivity rerun. Changing only the final digit to Harbor#Quill-4472 returns *EF288F2A452987D61E7623DD170EA2F840BAF4E1, so a typo anywhere produces a completely different hash and a rejected login, never a near miss. The number to watch is the length: 41 characters with a leading star means the 4.1 format, while 16 hex digits would signal the pre-4.1 method that modern servers refuse.

The caveat is the target version. Her staging image runs MySQL 8.4, where mysql_native_password is disabled by default, so the init script must start the server with --mysql-native-password=ON or the account cannot authenticate. On MySQL 9.0 this hash would fail outright, because the plugin no longer exists. For that case she would create the account with caching_sha2_password instead, and her next action is to open a ticket to migrate the one legacy reporting client before the 9.0 upgrade.

Change a MySQL Password with ALTER USER and IDENTIFIED BY

The generator's output slots straight into these statements, either after IDENTIFIED WITH ... AS or replaced by the plain text. To change MySQL password credentials for an existing account, run ALTER USER 'username'@'localhost' IDENTIFIED BY 'NewPassword';. The username and host must match the account exactly, because 'app_user'@'localhost' and 'app_user'@'%' are different accounts on the same server. Wrap the password in single quotes, and note that these SQL commands also work with CREATE USER for new accounts, while GRANT assigns privileges afterwards. The older SET PASSWORD statement still exists, but ALTER USER is clearer, and you can swap the plain text for a hash with the plugin name.

Pre-hashing fits provisioning jobs, where hashing a password once and committing only the hash keeps the password out of your repository. For an interactive session, plain IDENTIFIED BY is simpler, and the server does the hashing for you. Whichever route you take, rotate the password whenever someone who knew it leaves, and record which plugin each account uses, since a password hash from one plugin will not work under another.

MySQL Root Password and the Query Log

The MySQL root password deserves the same care: set it with ALTER USER on 'root'@'localhost'. The hash this page creates is the value that lands in backups and dumps, so the root hash needs the same protection as the password itself. The server rewrites password text before it reaches the general query log and the binary log, and the mysql client skips matching lines in its own history file. Even so, any hash left in logs still needs protection.

Strong Password Rules and Plain Text Password Risks

A strong password mixes length with variety, and the password validation component rejects weak values with ERROR 1819. For security, remember that a weak input also gives a weak MySQL hash, because the generator cannot add entropy. If a client then sees Access denied, check the credentials, the username and the host part first, and remember that special characters need percent-encoding inside connection strings.

Bcrypt and Password Hashing Beyond MySQL

Bcrypt is the usual choice for application logins, because it adds a salt and a tunable cost, whereas a MySQL account hash only serves the server's own authentication. Never store this page's output in your own users table. For application data, a slow algorithm such as bcrypt or scrypt resists guessing, and a Postgres project needs its own format anyway. Password hashing for an app and for a database account are separate jobs, and a password manager can generate password values for both. In Docker, Ansible or Terraform config management, keep the hash in a secret store instead of a SQL file in your repository, and MariaDB users should confirm the format first.

Keep the layers separate: the password a person types is hashed once by your application, and the password for the database account is hashed by the server. Treat both as secrets, because a leaked hash lets an attacker test guesses offline, and the account hash from this page deserves the same care as any application hash.

Password Hashing with Bcrypt for Web Developers

MySQL password hashing is a separate job from application hashing: when you build a login form, let the framework call bcrypt at registration and verify with the same library at sign-in, and use this page only for the database account. Pick a cost that takes roughly a quarter of a second on your server. The account hash only protects the database login, not your customers.

Frequently Asked Questions

What is this hash format used for?
This is the exact format MySQL's built-in PASSWORD() function has produced since MySQL 4.1 -- a double SHA-1 digest, uppercase hex, prefixed with an asterisk. It's used internally by MySQL for replication authentication and legacy account password storage, not for hashing passwords inside your own application.
Why double-hash with SHA-1 instead of hashing once?
The double-hash construction (SHA1(SHA1(password))) was specifically designed so that MySQL's server-side authentication challenge-response protocol never needs to see the plain SHA1(password) value, which alone would be enough to authenticate as that user -- it's a protocol design choice from the era, not a modern security best practice by today's standards.
Is this format secure for storing application passwords?
No -- like plain SHA-1 or MD5, this is a fast hash with no salt and no iteration count, making it fast to brute-force with modern hardware. It exists here purely to replicate MySQL's own internal authentication format, which you may need for MySQL replication setup or legacy account migration -- not as a recommendation for hashing passwords in your own application (use bcrypt or Argon2 for that).
Does this match what CREATE USER ... IDENTIFIED BY PASSWORD produces?
Yes, for the legacy mysql_native_password authentication plugin -- this is exactly the hash format stored in the mysql.user table's authentication_string column when using that plugin. Newer MySQL versions default to caching_sha2_password, which uses a different (unpublished, salted) scheme this tool does not replicate.
Is my password sent anywhere?
No. The hash is computed entirely in your browser using the Web Crypto API -- nothing is transmitted to a server or stored.

About the author

Vinitha Pu

Founder and designer

Vinitha Pu is a graphic designer based in Palakkad, Kerala, who builds free, privacy-friendly browser tools. She studied Textile and Apparel Design at Avinashilingam University and completed a C-Tech in Graphic Design at Image Creative Education in 2025. She designs, builds and maintains the password generators, strength checkers, hash tools and security calculators on PasswordHive.

  • Content author: Vinitha Pu
  • Fact checked by: Vinitha Pu. Each tool's output is checked against official test vectors or a reference implementation, and every strength and crack-time figure against the formula it uses, before it goes live.
  • Published Updated