Last Updated on July 21, 2026 by skraito with Lord Jesus Christ
To reset your WordPress administrator password using the MariaDB root account via the command line, you need to log into the MariaDB monitor, target the correct WordPress database, and run an UPDATE query using an MD5 hash.
Step 1: Log in to MariaDB as Root
Open your server terminal or connect via SSH. Run the following command to access your database monitor:
bash
mysql -u root -p
Use code with caution.
- Type your MariaDB root password when prompted and press Enter.
Step 2: Select Your WordPress Database
If you do not remember the exact name of your WordPress database, list all available databases:
sql
SHOW DATABASES;
Use code with caution.
Once identified, select it by running:
sql
USE your_database_name;
Use code with caution.
(Replace your_database_name with your actual database name).
Step 3: Identify Your Admin Username
List all the existing users and their respective IDs to find your correct username:
sql
SELECT ID, user_login, user_email FROM wp_users;
Use code with caution.
- Note: If you configured a custom database prefix during your installation, your table might be named something like
wp_customprefix_usersinstead ofwp_users.
Step 4: Run the Password Update Query
WordPress uses MD5 hashing for basic compatibility in database updates. Run the following query to assign a new password:
sql
UPDATE wp_users SET user_pass = MD5('your_new_password') WHERE ID = 1;
Use code with caution.
- Replace
'your_new_password'with your actual desired password. - Replace
ID = 1with the exact numerical ID discovered in Step 3.
Step 5: Exit the Monitor
Once the terminal reports that the row has been successfully changed, type the exit command:
sql
flush privileges;
exit;