GoAdmio

wordpress-password

Reset the password of a WordPress site's first user (ID 1) from the command line, and show its username and email

On this page: Overview · Quick start · Syntax · Options · Output · Examples · Troubleshooting · Details · See also


Overview

/go/wordpress-password resets a WordPress login when you can't get in, for example if the password was lost and the "Lost your password?" email doesn't arrive. It finds the site's WordPress database from its wp-config.php file and sets a new password directly in the database.

It changes the password of the WordPress user with ID 1, which is normally the administrator account created when WordPress was installed. It does not change any other user.

The command runs sudo internally, so run it as root or as a user with sudo rights. It needs MariaDB, and the site's wp-config.php must be at /home/<domain>/www/wp-config.php.

[!WARNING] The new password is written to a log in plain text. /var/log/go/wordpress-password.log records every argument you pass, including the password, and the command prints the password on screen. Remove the line from the log afterward if it may be shared, and change the password again from the WordPress dashboard if you want to be sure no one else knows it.


Quick start

# Reset the first WordPress user's password
/go/wordpress-password example.com 'N3w-Str0ng-Pass'

Syntax

# Give the domain and password directly
/go/wordpress-password <domain> '<new-password>'

# Or run with no arguments to be asked for them
/go/wordpress-password
Form Behavior
/go/wordpress-password <domain> '<password>' Resets the password for that domain's WordPress site.
/go/wordpress-password Asks for Domain: and then Password:. What you type for the password is visible on screen.

Every run is recorded in /var/log/go/wordpress-password.log, with the time and the arguments you passed.


Options

Argument Required Notes
domain Yes The account's domain, with a /home/<domain> folder.
password Yes The new password. Put it in single quotes.

[!WARNING] Always give both arguments. If you give only the domain, the new password is empty.


Output

WordPress Username: admin
WordPress Email: admin@example.com
WordPress Password: N3w-Str0ng-Pass

WordPress Password has been modified successfully.
Message Meaning
Account <domain> not exists. There is no /home/<domain> folder. Exit status 1.
WordPress not installed. There is no wp-config.php in /home/<domain>/www.
WordPress Password has been modified successfully. The command finished. This is printed even if the database update didn't work, so check the username and email above it.

If the WordPress Username and WordPress Email lines are blank, no user with ID 1 was found and nothing was changed.

Log

Each run appends one line to /var/log/go/wordpress-password.log, including the password:

[Nov 21 12:00:00]# wordpress-password example.com N3w-Str0ng-Pass

Examples

# Reset the password
/go/wordpress-password example.com 'N3w-Str0ng-Pass'
# Be asked for the domain and password
/go/wordpress-password

Troubleshooting

Symptom Likely cause Fix
Account <domain> not exists. The domain is misspelled, or has no folder under /home. Check the name.
WordPress not installed. wp-config.php isn't in /home/<domain>/www. WordPress installed in a subfolder isn't found. Reset the password another way, or move to the folder that holds wp-config.php.
The username and email are blank The user with ID 1 doesn't exist, or the database name or table prefix in wp-config.php couldn't be read. Check wp-config.php, and look at the users table in the database.
The password works for the wrong person, or the admin you want isn't changed The user with ID 1 isn't the account you meant. Log in as that user, then change the other accounts from the WordPress dashboard.
An SQL error appears, or the password doesn't work The password contains a single quote (') or a backslash (\), or wasn't quoted in the shell. Use a password without those characters and put it in single quotes.
The login says the password is empty or wrong after a run with only a domain The password argument was missing. Run again with both arguments.
You still can't log in A security plugin, two-factor login, or a changed login address is in the way. Check the plugin's settings, or the login address, with the user shown in the output.

Details

What it does

Step Action
1 Checks that /home/<domain> exists.
2 Looks for /home/<domain>/www/wp-config.php.
3 Reads the table prefix (for example wp_) and the database name from wp-config.php.
4 Reads the username and email of user ID 1 from the <prefix>users table.
5 Sets that user's password to the MD5 hash of the new password.
6 Prints the username, email, and password.

The command reads wp-config.php with simple text matching, so it expects the standard layout, with the table prefix and DB_NAME each on one line and in single quotes. An unusual layout can cause the wrong database or table to be used.

WordPress still accepts an MD5 password hash, and it replaces it with a stronger one the next time that user logs in successfully.


See also

Command Description
password Change a GoAdmio account's FTP, SSH, and panel login password for one domain or all domains
mysql Create, edit, or delete a MySQL/MariaDB database and user for a hosting account
mysqlset Change the MySQL root password