Friday, 8 March 2013

Reset WP-admin password from shell

1. Open a bash shell on the linux box. Using SSH is advised.

2. Generate a password MD5 hash using php.
# php -r "print( md5('YourPassWordHere')); print(\"\r\n\");"

3. Copy the 32 bit string that is the result.

4. Connect to mysql

5. Connect to the correct database;
show databases;
use databasename;

6. make a copy/paste backup of the admin user data.
select * from wp_users where user_login = 'admin';

7. Update the table
update wp_users set user_pass='the_md5_hash_generated_in_step_2/3' where user_login = 'admin';

8. Log into wordpress using the username “admin” and the password you have used.

9. Reset you password using the “wordpress dashboard > Users > Your profile > Change password” option.