Reset Your Wordpress Password Easily Using These 4 Simple Methods
Reset Your Wordpress Password Easily Using These 4 Simple Methods
(C) Google Image; Fixrunner: How to Change or Reset Wordpress Password |
Are you locked out of WordPress, because you forgot your password? Such things do happen, and quite common too. Not to worry, in this post, I'll share with you four (4) quick and easy steps to reset your password in WordPress, and set you back on your feet quickly.
Method One: Reset Your Password By Using WordPress Password Reset Link
This method is applicable if you still remember, and have access to the email address you registered WordPress with. To reset your password using this method, head on to www.yoursite/wp-admin and click on the reset password link. Fill in the required details, and follow the instructions to set up your new password.
Method Two: Reset Your Password From Your WordPress Dashboard
This method is applicable where you still have access to your WordPress dashboard, but cannot remember the actual password you used any longer. This is of course possible where you auto saved your login details in your browser.
But you must not rely on that cos, you may need to login with another device entirely with a different browser. Also, you may lose that auto-login ability when you clear your browser cache and history.
Unfortunately, you cannot view your password in WordPress even while you're in the dashboard. But you can view your username, change your password, and reset your password right from within the dashboard.
In order to reset your password within the dashboard in WordPress, you will need to navigate to Users→Your Profile→Account Management→New Password→Generate Password
When done, scroll down and click on Update Profile
Method Three: Reset Your Password In MySQL Database
This method will require that you have access to MySQL database via the C panel of your server. In order to reset your password using this method, you must login to your C panel, and click on phpMyAdmin.
You should then see a list of your databases. Click on 'connect' or 'connect now' whatever is displayed in your server, in order to connect to the database.
Click on the users table. Your own table prefix may be different from the one shown in the image below
Click on browse, in order to expand the role.
Now, click on the small pencil icon towards the left to open the edit dialog, where you will be able to type in your new password
Delete the old password, input the new one, and change the encryption to MD5. This is supported in lower versions of WordPress, and will be updated if you are using a newer WordPress version.
After all has been set, click on go to apply and save your changes.
CONGRATULATIONS! You have successfully changed your password from the database.
Method Four: Reset Your Password Using the Emergency Password Reset Script
There are two common methods of doing this, and each entails uploading a PHP script to your server. There are words of caution to follow however, in applying these methods:
- Warnings
- Requires you know the administrator username.
- It updates the administrator password and sends an email to the administrator's email address.
- If you don't receive the email, the password is still changed.
- You do not need to be logged in to use it. If you could login, you wouldn't need the script.
- Place this in the root of your WordPress installation. Do not upload this to your WordPress Plugins directory.
- Delete the script when you are done for security reasons.
- Directions for use
- Save the script as a file called emergency.php to the root of your WordPress installation (the same directory that contains wp-config.php).
- In your browser, open http://example.com/emergency.php
- As instructed, enter the administrator username (usually admin) and the new password, then click Update Options. A message is displayed noting the changed password. An email is sent to the blog administrator with the changed password information.
- Delete emergency.php from your server when you are done. Do not leave it on your server as someone else could use it to change your password.
<?php /* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ require './wp-blog-header.php'; function meh() { global $wpdb; if ( isset( $_POST['update'] ) ) { $user_login = ( empty( $_POST['e-name'] ) ? '' : sanitize_user( $_POST['e-name'] ) ); $user_pass = ( empty( $_POST[ 'e-pass' ] ) ? '' : $_POST['e-pass'] ); $answer = ( empty( $user_login ) ? '<div id="message" class="updated fade"><p><strong>The user name field is empty.</strong></p></div>' : '' ); $answer .= ( empty( $user_pass ) ? '<div id="message" class="updated fade"><p><strong>The password field is empty.</strong></p></div>' : '' ); if ( $user_login != $wpdb->get_var( "SELECT user_login FROM $wpdb->users WHERE ID = '1' LIMIT 1" ) ) { $answer .="<div id='message' class='updated fade'><p><strong>That is not the correct administrator username.</strong></p></div>"; } if ( empty( $answer ) ) { $wpdb->query( "UPDATE $wpdb->users SET user_pass = MD5('$user_pass'), user_activation_key = '' WHERE user_login = '$user_login'" ); $plaintext_pass = $user_pass; $message = __( 'Someone, hopefully you, has reset the Administrator password for your WordPress blog. Details follow:' ). "\r\n"; $message .= sprintf( __( 'Username: %s' ), $user_login ) . "\r\n"; $message .= sprintf( __( 'Password: %s' ), $plaintext_pass ) . "\r\n"; @wp_mail( get_option( 'admin_email' ), sprintf( __( '[%s] Your WordPress administrator password has been changed!' ), get_option( 'blogname' ) ), $message ); $answer="<div id='message' class='updated fade'><p><strong>Your password has been successfully changed</strong></p><p><strong>An e-mail with this information has been dispatched to the WordPress blog administrator</strong></p><p><strong>You should now delete this file off your server. DO NOT LEAVE IT UP FOR SOMEONE ELSE TO FIND!</strong></p></div>"; } } return empty( $answer ) ? false : $answer; } $answer = meh(); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>WordPress Emergency PassWord Reset</title> <meta http-equiv="Content-Type" content="<?php bloginfo( 'html_type' ); ?>; charset=<?php bloginfo( 'charset' ); ?>" /> <link rel="stylesheet" href="<?php bloginfo( 'wpurl' ); ?>/wp-admin/wp-admin.css?version=<?php bloginfo( 'version' ); ?>" type="text/css" /> </head> <body> <div class="wrap"> <form method="post" action=""> <h2>WordPress Emergency PassWord Reset</h2> <p><strong>Your use of this script is at your sole risk. All code is provided "as -is", without any warranty, whether express or implied, of its accuracy, completeness. Further, I shall not be liable for any damages you may sustain by using this script, whether direct, indirect, special, incidental or consequential.</strong></p> <p>This script is intended to be used as <strong>a last resort</strong> by WordPress administrators that are unable to access the database. Usage of this script requires that you know the Administrator's user name for the WordPress install. (For most installs, that is going to be "admin" without the quotes.)</p> <?php echo $answer; ?> <p class="submit"><input type="submit" name="update" value="Update Options" /></p> <fieldset class="options"> <legend>WordPress Administrator</legend> <label><?php _e( 'Enter Username:' ) ?><br /> <input type="text" name="e-name" id="e-name" class="input" value="<?php echo attribute_escape( stripslashes( $_POST['e-name'] ) ); ?>" size="20" tabindex="10" /></label> </fieldset> <fieldset class="options"> <legend>Password</legend> <label><?php _e( 'Enter New Password:' ) ?><br /> <input type="text" name="e-pass" id="e-pass" class="input" value="<?php echo attribute_escape( stripslashes( $_POST['e-pass'] ) ); ?>" size="25" tabindex="20" /></label> </fieldset> <p class="submit"><input type="submit" name="update" value="Update Options" /></p> </form> </div> </body> </html> <?php exit; ?>
The above code is available here
Another code similar to the one given above, is a script written by Nicolas Kuttler, a software and systems engineer from France, available at his website.
A snapshot of the code is given below:
<?php $user_id = 1; # Insert your user ID or simply 1 for the first user that was created $user_pass = 'secret'; # Insert a new password $ip = '127.0.0.1'; # Insert your IP if ($_SERVER['REMOTE_ADDR'] === $ip) { require_once(ABSPATH . WPINC . '/registration.php'); require_once(ABSPATH . WPINC . '/pluggable.php'); $user = wp_update_user(array( 'ID' => $user_id, 'user_pass' => $user_pass, )) ; var_dump(get_userdata($user)); die('disable me!'); }
According to Nicolas, in order to use this code, you have to edit it, and fill in the proper values. Then upload it to the wp-content/mu-plugins/ directory, create the directory if necessary.
The code will run automatically, there's no need to activate it like a plugin, but you have to delete the file after using it.
The script may also fail if there is no user with an ID of 1.
This code will run automatically by going to your website, and must be uploaded to the wp-content/mu-plugins/ directory, even if you are not using multi-user. The code does not need to have a specific name on the server.
Another version of the script that he wrote which must also be uploaded to the wp-content/mu-plugins/ directory is given below. You need ftp access to your host to upload these scripts.
<?php /** * Upload to wp-content/mu-plugins/whichevernameyoulike.php */ $login = 'foobar'; # New username $password = 'barbaz'; # Password for the new user $email = 'you@example.com'; # Email address of the new user $ip = '127.0.0.1'; # Insert your IP, http://google.com/search?&q=what%20is%20my%20ip if ($_SERVER['REMOTE_ADDR'] === $ip) { require_once(ABSPATH . WPINC . '/pluggable.php'); require_once(ABSPATH . 'wp-admin/includes/' . 'user.php'); $userdata = array( 'user_login' => $login, 'user_pass' => $password, 'user_email' => $email, 'role' => 'administrator', ); $user_id = wp_insert_user($userdata); var_dump($user_id); die('delete me!'); }
For the code to work, you must insert the necessary details, including your IP Address.
To learn more about this code, follow the link below
I hope these methods help you resolve your password issue successfully in WordPress, if so, share your comments below, and what method you used to resolve the issue
Post a Comment