011. Use the reset link (if email works)
On the login page choose Lost your password? and enter the username or email address. If the email does not arrive, check spam, then check whether the site can send email at all: many hosts block PHP mail, which is why an SMTP plugin is worth setting up.
022. WP-CLI (if you have SSH access)
WP-CLI is the quickest and safest option on a server. From the site's folder, list the users, then send a reset email or set a new password:
wp user list --role=administrator
wp user reset-password admin-username
wp user update admin-username --user_pass="a-long-new-password"
Setting a password on the command line can leave it in your shell history, so prefer the reset email or clear the history afterwards.
033. The database (phpMyAdmin)
If you only have hosting control panel access, open phpMyAdmin, take a backup of the database first, then edit the admin user in the wp_users table (the prefix may differ). Set user_pass to a new password using the MD5 function. WordPress accepts it once and replaces it with a stronger hash when you log in. You can also correct user_email here if the address is out of date.
044. A temporary code snippet (last resort)
With file access only, a one-line call to wp_set_password() in the active theme's functions.php resets the password on the next page load. It must be removed immediately afterwards, because it runs on every request. Only use this if the other three options are not available.
05Afterwards: check why it happened
- Make sure every administrator account belongs to a real, current person, and remove old developer accounts.
- Use a password manager and turn on two-factor authentication for administrators.
- If you did not change the password yourself, treat it as a possible compromise: check users, recently changed files and plugins, and change hosting and database passwords.
- Set up reliable email sending so future reset links arrive.