If you administer the WordPress site and can reach its MySQL/MariaDB database (through phpMyAdmin, WP-CLI, or a direct client), you can reset an account's password by writing a new hash into the wp_users.user_pass column—because WordPress stores passwords as one-way hashes, not recoverable plaintext, so "getting" the password really means replacing it, not decrypting it.

What the database actually stores, and why "retrieval" is the wrong frame

WordPress hashes passwords with a portable PHP implementation of bcrypt (since WordPress 6.8; earlier versions used phpass, which is MD5-based with a stretched loop). The stored value looks like $wp$2y$10$... on current releases or $P$B... on older ones. Each hash is salted, so the same plaintext password yields different strings on different sites and even different accounts. There is no reversible encryption step, no master key sitting in the database, and no "show password" column.

That means three facts govern the whole exercise:

1: Legitimate recovery is a reset, not an extraction. You generate a new hash for a password you choose, or trigger WordPress's own reset flow. 2: The database is one of several routes. WordPress's password-reset email, WP-CLI's wp user update, and a small must-use plugin all accomplish the same thing without touching SQL directly. The database route matters when email is broken, the admin account is inaccessible, or you have only database credentials. 3: Any method that writes to wp_users presumes you already control the site's backend. That is the boundary between administration and intrusion, and it is the line this answer stays on the correct side of.

The table prefix is not always wp_. Multisite installs, hosts that harden against SQL injection, and many managed hosts use prefixes like wp3f2_ or a custom string. Check wp-config.php for $table_prefix before assuming wp_users exists under that name.

The SQL route step by step

The procedure below assumes a single-site install, direct database access, and a password you are entitled to set. It is the standard administrator's method and is documented in WordPress support material.

Step 1: Identify the target row. In phpMyAdmin or a MySQL client:

Confirm which account you need. If you are locked out entirely, pick the administrator account; the wp_usermeta table's wp_capabilities row tells you which users are administrators, though the exact meta key depends on the prefix (wp_capabilities vs. {prefix}capabilities).

Step 2: Generate a hash. Do not hand-type one. The reliable way is to let WordPress itself produce it:

WP-CLI (preferred if you have shell access): wp user update 1 --user_pass='your-new-password' writes a correctly formatted hash and updates caches. This is cleaner than SQL and avoids format mistakes. A throwaway PHP snippet using wp_hash_password() on the site's own WordPress installation. A well-known online hash generator is common advice but represents a real risk: you are sending a password to a third party. Use it only for a temporary password you will immediately change.

A bcrypt hash for WordPress 6.8+ begins $wp$2y$. An older phpass hash begins $P$. If you paste a hash in the wrong format, WordPress's wp_check_password() will fail the comparison and you will be locked out again with no error message beyond "incorrect password."

Step 3: Write the new value.

Use a parameterized query or phpMyAdmin's edit form rather than string concatenation, because a $ or quote mishandled in shell quoting silently corrupts the hash. Verify with a SELECT that the value round-trips intact.

Step 4: Clear caches and log in. WordPress caches user objects; object caches (Redis, Memcached) and page caches can serve stale authentication state. Flush them, then log in and change the password again through the dashboard so the final secret is one only you know.

Where this stops working, and the traps

Multisite changes the target. In a WordPress network, users live in the base site's wp_users table, but capabilities are per-site in wp_{blog_id}_capabilities. Writing to the wrong table, or assuming a per-site user table, produces a "successful" update that grants nothing.

Some hosts lock down direct SQL writes to user tables. Managed WordPress platforms often restrict UPDATE on wp_users or route authentication through SSO. In that setting, the database route fails by design; the host's own reset tool is the supported path.

Password hashes survive migration; salts do not travel with them. The AUTH_KEY, SECURE_AUTH_SALT, and related constants in wp-config.php are not in the database. If you copy a hash from one install to another, the hash still validates because bcrypt verification is self-contained in the stored string—but cookies and sessions from the old install will not, and users will be logged out.

Changing user_pass does not revoke sessions. WordPress stores session tokens in wp_usermeta under session_tokens. A stolen session remains valid until it expires or you destroy those tokens. For a suspected compromise, also update the salts in wp-config.php (which invalidates all cookies) and delete the session_tokens meta row.

The user_activation_key column is not a backdoor. It is used for password-reset requests and is hashed; editing it does not grant login. Some older tutorials conflate it with a reset mechanism. It is not one.

Two-factor plugins sit in front of the password. If a 2FA plugin is active, a correct password still lands on a verification step. Regaining database access does not bypass that; you would need to disable the plugin or clear its user meta, which is a separate administrative action with its own audit implications.

The honest ambiguity in the question

"Using a database to get a WordPress password" can mean at least three different things, and they have very different answers:

I forgot my admin password and have database access. The reset procedure above applies. This is a legitimate recovery scenario and the one most searchers mean. I have a database dump and want to recover a user's original plaintext password. This is not generally possible. Bcrypt and phpass are deliberately slow and salted; offline cracking works only for weak passwords and is a different activity with legal and ethical weight depending on whose data it is. I want to obtain someone else's password without authorization. No legitimate method exists, and the techniques that purport to do it—credential phishing, malicious plugins, database injection—are computer-crime territory in the U.S. under the Computer Fraud and Abuse Act and equivalents elsewhere. The absence of a "decrypt" function is not an oversight; it is the security property.

The answer above addresses the first meaning. The second is technically bounded (hash cracking, not retrieval). The third is out of scope for any responsible technical answer, and the distinction is not pedantic: the same SQL syntax appears in all three, which is why tutorials often blur them.

Hash vs. encryption. Hashing is one-way and salted; encryption is reversible with a key. Saying "the database stores an encrypted password" is a common and consequential error. wp_hash_password() / wp_check_password() are the WordPress functions that generate and verify hashes. They are pluggable, which is how security plugins swap in Argon2. wp_set_password() is the older function that writes a hash directly; it does not clear caches, which is why WP-CLI is preferred. "Salts" in WordPress (AUTH_KEY, etc.) are not password salts—they are keys for signing cookies. The password salt lives inside the hash string. Confusing the two is endemic in forum advice. $P$B vs. $wp$2y$ is the quickest way to tell whether a hash is old phpass or modern bcrypt, which matters if you are migrating or troubleshooting.

A practical caution about the "online generator" shortcut

The most-repeated version of this tutorial tells you to paste a hash from a website into phpMyAdmin. Two things go wrong. First, the generator may produce phpass format while the site expects bcrypt, or vice versa, and the failure is silent. Second, you have now transmitted a password to an unknown server. The safer sequence is always: use WP-CLI if available; otherwise use a local PHP one-liner against the site's own wp-includes/class-phpass.php or wp_hash_password(); use an online tool only for a temporary value you rotate immediately. None of these require guessing at formats.

Bottom line

You cannot retrieve a WordPress password from the database because only a salted one-way hash is stored; you can, with legitimate database access, replace it by writing a correctly generated hash into wp_users.user_pass, and you should prefer WP-CLI or WordPress's own reset flow because they avoid format and cache errors. The method is a recovery tool for administrators, not a decryption tool, and the distinction between those two is the whole answer.