How to directly change the administrator password in WordPress

Source: Internet
Author: User
Tags php file php code administrator password phpmyadmin wordpress database

1. Modify the wp administrator user name through phpmyadmin:

This method is intuitive and simple, and is suitable for beginners. We use the mysql management tool phpmyadmin provided by the php virtual host to modify the settings.

1. Log on to the control panel of the carefree host, find phpmyadmin, and click enter database account password to log on

Open the WordPress database, select "wp_users" in the database table, and click browse to view your wp administrator account. Generally, the ID is 1.


2. Find the field names user_login and user_nicename, and change the admin name to the user name you want to change. After the command is executed, you can.


II. Quick use of SQL commands

We recommend that you do not use this method for new users, because it is not so intuitive and may be modified by yourself. Open your WordPress database, click SQL following the structure, and enter the following command: (do not forget to execute it)

The code is as follows: Copy code

"Update user set password = password (" new password ") where user = 'username ';"

3. Use the following php code to directly change the wordpress administrator password

Php complete code is as follows, create a new reset_password.php file, copy the following php code, paste to rest_password.php, convert the format to UTF-8 without bom encoding, save, and then upload to the same directory as the wp-config.php. Enter/reset_password.php in the browser (replace wentong.org with your domain name) and enter the new password.
After the password is reset, you must immediately delete the reset_password.php file. Otherwise, the consequences will be borne by you.

The code is as follows: Copy code

<? Php
/**
* Tool for modifying the WordPress website password.
* Filename: reset_password.php
* @ By meimi Studio
*/
Include ("wp-config.php ");
Include ("wp-blog-header.php ");
If (empty ($ _ POST ['emergency _ pass']) {
?>
<Form method = "post">
Enter the expected administrator password: <input name = "emergency_pass" type = "password"/>
<Input type = "submit"/>
<Br/> after the password is submitted, it is automatically transferred to the WordPress website logon page.
<Br/> <font size = "" color = "red"> Note: After submission, delete the password reset file to ensure website security. </Font>
<Br/> All rights reserved & copy; even meters Studio
</Form>
<? Php
} Else {
$ SQL = "UPDATE ". $ wpdb-> users. "SET user_pass = '". md5 ($ _ POST ['ergency _ pass']). "'Where User_login = 'admin '";
$ Link = $ wpdb-> query ($ SQL );
Wp_redirect ('WP-login. Php ');
Exit ();
}
?>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.