How to Reset a Wordpress Password


If you have forgotten your wordpress credentials, or possibly have had your wordpress install compromised; you may find yourself needing to change your admin username and/or password to regain access to your site.

There are two fairly easy ways to do so.

Warning: Please be sure to make backups of all of your data before attempting to perform any steps listed here. Please also note that this article assumes you do not currently have any access to wordpress. If you are able to log in to wordpress, please follow the instructions here: http://codex.wordpress.org/Resetting_Your_Password



 
Reset a User's password through MySQL

  • Log in to your wordpress database using MySQL's command line interface
  • Find the ID of the user's password you want to change
SELECT ID, user_login, user_pass FROM wp_users;
  • Change that user's password to a new one
UPDATE wp_users SET user_pass=MD5('newstrongpassword') WHERE ID = usersID;


Reset a User's Password through phpMyAdmin

If you have Plesk or cPanel, phpmyadmin should be included by default. Open it up for the domain and database that your wordpress site belongs on. If you don't remember the database name, look in your wp-config.php for a line similar to this:

define('DB_NAME', 'wordpress_blog');

In this example, "wordpress_blog" is the name of the database.

  • Once you're logged in to phpmyadmin, click on the wp_users table.
  • Make sure you are on the browse screen
  • Find the username you want to change the password for
  • Click edit on that username
  • Enter in your new password in the Value field of the user_pass line
  • Select "MD5" from the dropdown under the Functions column for the user_pass line
  • Click Go at the bottom of the screen, and then you should be able to log in with the new password


How to Create a new Wordpress Admin User

If your admin user no longer exists, for whatever reason, you may find yourself needing to create an entirely new user to use.


Create a New Admin User using phpmyadmin

If you have Plesk or cPanel, phpmyadmin should be included by default. Open it up for the domain and database that your wordpress site belongs on. If you don't remember the database name, look in your wp-config.php for a line similar to this:

define('DB_NAME', 'wordpress_blog');

In this example, "wordpress_blog" is the name of the database.

  • Once you're logged in to phpmyadmin, click on the wp_users table.
  • Click the Insert tab
  • Fill out the Value for all of the fields using your own information
    • For user_pass, select "MD5" under the Function column, and put in the password as plaintext in the Value column.
    • Set user_status to 0
    • Make sure you don't use a ID or user name that is already in use
  • Once you insert the new user, click on the wp_usermeta table
  • Click the Insert tab
  • Fill out the Value for all of the fields
    • Leave unmeta_id blank, it will auto-increment on its own
    • Make sure user_id matches the number you put in the ID field previously
    • meta_key should be: wp_capabilities
    • meta_value should be: a:1:{s:13:”administrator”;b:1;}
  • Insert another row on the same wp_usermeta table
    • Leave unmeta_id blank again
    • user_id should still be the same ID from the wp_users table
    • meta_key should be: wp_user_level
    • meta_value should be: 10
  • Click Go to insert these two rows.
  • Now go log in to wordpress /wp-admin/ with the user you just created
    • Make sure you click on Users and edit the new user. Correct any information if you need to, but just clicking save should be enough as wordpress will automatically create the rest of the metadata that it needs.

 


Create a New Admin User using mysql

A quicker approach, if you are familiar with logging into the mysql cli through ssh or want to execute queries using php or phpmyadmin, is to run these directly. You'll need to edit the databasename first, and change the values for the new user.

USE wordpress_blog;

INSERT INTO wp_users (´ID´, ´user_login´, ´user_pass´, ´user_nicename´, ´user_email´, ´user_url´, ´user_registered´, ´user_activation_key´, ´user_status´, ´display_name´) VALUES ('50000', 'admin', MD5('strongpassword'), 'First Last', 'admin@domain.com', 'http://www.example.com/', '2013-01-13 00:00:00', , '0', 'First Last');
 
INSERT INTO wp_usermeta (´umeta_id´, ´user_id´, ´meta_key´, ´meta_value´) VALUES (NULL, '50000', 'wp_user_level', '10');

INSERT INTO wp_usermeta (´umeta_id´, ´user_id´, ´meta_key´, ´meta_value´) VALUES (NULL, '50000', 'wp_capabilities', 'a:1:{s:13:"administrator";b:1;}');
Posted in
Last update:
2015-12-03 20:39
Average rating:0 (0 Votes)