Restring With The Help Of phpMyAdmin
On the left hand side of phpMyAdmin, you will see a list of database names. You need to click the database that corresponds to wordpress.
You will then be able to see all the tables within the database, you will need to click on wp_users from that list, you are then looking for your username under user_login. When you have found this, you will need to click edit.
First you need to check the value for user_login matches your username, if it does you will need to delete the random string in the value box for user_pass. You can then type your new desired password, be aware passwords are case sensitive. After you have typed the password select the drop down box shown in the image bellow and pick MD5 from the list of options.
After you have done this, just double-check the password you have set in the value box for user_pass is the password you desire. If your happy with the password then click go in the bottom right.
Right you can now test the new password by trying to login into WordPress.
Resetting Through FTP
To start with we will need our FTP access details, these can be seen in the hosting control panel. On the left hand side select “FTP/User Account” -> “FTP User“. From here you will need to take note of the login, password and host name as these will need to be entered into your FTP client, alternately you can always click on the login button on this page which will then provide you access with a web based FTP client.
You will then need to navigate to the functions.php file for the active theme. So you need to select the domain name you have installed wordpress to, then browse the wp-content folder and select themes. You should now have a few folders, each name corresponding to the name of a WordPress theme, you will need to select the theme you currently have active. Now we need to locate the functions.php file. You can either edit it directly inside your FTP client if it allows you or download the file to edit on your own PC/Laptop before saving the changes and uploading the file over writing the old version.
At the top of this file just after “<?php” we need to place the following text:
wp_set_password( 'temppasswd', 1 );
Setting “temppasswd” to what ever temporary password you want. The number one corresponds to the user ID in the wp_users table. In most cases the number one will point to the admin user account.
You should now be able to login with the new password. Once you are logged in the text will need to be removed from the file. You can then set a new password from within WordPress.
Deleted the admin account!
This section will cover what you need to do if the admin account is ever deleted by mistake. We require phpMyAdmin access to recreate the admin account, if you need help accessing this first take a look at the following guide.
On the left hand side of phpMyAdmin, you will see a list of database names. You need to click the database that corresponds to wordpress.
To create the admin account we need to run an SQL query, so from the tool bar at the top left of the page select the little box with the word “SQL” inside it.
This should load a new window, which will allow us to run our query against the database. Below is the query we will need to run, I have highlighted the sections you will need to make changes to.
INSERT INTO `wp_users` (`user_login`, `user_pass`, `user_nicename`, `user_email`, `user_status`) VALUES ('INSERT_USERNAME_HERE', MD5('INSERT_PASSWORD_HERE'), 'INSERT_FIRSTNAME_LASTNAME>', 'INSERT_EMAIL_HERE', '0'); INSERT INTO `wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`) VALUES (NULL, (Select max(id) FROM wp_users), 'wp_capabilities', 'a:1:{s:13:"administrator";s:1:"1";}'); INSERT INTO `wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`) VALUES (NULL, (Select max(id) FROM wp_users), 'wp_user_level', '10');
After you have copied this text into the “Run SQL query” box then click go in the bottom right.
The page will now reload, after this has been done you should be able to login to WordPress again using the details you just setup.
Classification: Public
Last saved: 2019/08/14 at 15:17 by Jamie