FILEEM

POWER OF DREAM

wordpress忘记登录密码,更改域名的办法。

我们配置wordpress的时候常犯这样的错误:改了域名才发现域名还没解析过来,用自动生成的密码却忘了保存。

这时候,我们需要更改域名或修改wordpress登录密码。
《wordpress忘记登录密码,更改域名的办法。》

修改登录密码

登上数据库,如果mysql不能登录可以使用mysql -u username -p账号密码可以在WP根目录wp-config.php中找到。

root@ubuntu:~# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 25
Server version: 5.7.21-0ubuntu0.16.04.1 (Ubuntu)

Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

显示所有的数据库

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
| wp1719884          |
+--------------------+
5 rows in set (0.00 sec)

选择wordpress的数据库,我的是wp1719884

mysql> use wp1719884  ;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed

显示这个数据库下的表

mysql> show tables;
+-----------------------+
| Tables_in_wp1719884   |
+-----------------------+
| wp_commentmeta        |
| wp_comments           |
| wp_hermit             |
| wp_hermit_cat         |
| wp_links              |
| wp_options            |
| wp_postmeta           |
| wp_posts              |
| wp_term_relationships |
| wp_term_taxonomy      |
| wp_termmeta           |
| wp_terms              |
| wp_usermeta           |
| wp_users              |
+-----------------------+
14 rows in set (0.00 sec)

显示wp_users这个表的具体信息

mysql> desc wp_users;
+---------------------+---------------------+------+-----+---------------------+----------------+
| Field               | Type                | Null | Key | Default             | Extra          |
+---------------------+---------------------+------+-----+---------------------+----------------+
| ID                  | bigint(20) unsigned | NO   | PRI | NULL                | auto_increment |
| user_login          | varchar(60)         | NO   | MUL |                     |                |
| user_pass           | varchar(255)        | NO   |     |                     |                |
| user_nicename       | varchar(50)         | NO   | MUL |                     |                |
| user_email          | varchar(100)        | NO   | MUL |                     |                |
| user_url            | varchar(100)        | NO   |     |                     |                |
| user_registered     | datetime            | NO   |     | 0000-00-00 00:00:00 |                |
| user_activation_key | varchar(255)        | NO   |     |                     |                |
| user_status         | int(11)             | NO   |     | 0                   |                |
| display_name        | varchar(250)        | NO   |     |                     |                |
+---------------------+---------------------+------+-----+---------------------+----------------+
10 rows in set (0.00 sec)

只需要关心user_pass这一列,这是用户fileem的密码

mysql> select *from wp_users;
+----+------------+------------------------------------+---------------+--------------------+----------+---------------------+---------------------+-------------+--------------+
| ID | user_login | user_pass                          | user_nicename | user_email         | user_url | user_registered     | user_activation_key | user_status | display_name |
+----+------------+------------------------------------+---------------+--------------------+----------+---------------------+---------------------+-------------+--------------+
|  1 | fileem     | $P$BhHKJLymYSaMlcZfwXujuZQkFmkp. | fileem        | yourname@mail.com |          | 2018-11-10 10:19:41 |                     |           0 | yourname         |
+----+------------+------------------------------------+---------------+--------------------+----------+---------------------+---------------------+-------------+--------------+
1 row in set (0.00 sec)

用123456替换掉原密码

mysql> UPDATE wp_users SET user_pass = MD5( '123456' ) WHERE user_login = 'fileem';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 0

退出,完成,密码重置为123456


mysql> quit Bye

修改域名

在wp-config.php中,添加以下两行内容:

define('WP_HOME','http://新网址');
define('WP_SITEURL','http://新网址');

点赞

发表评论

电子邮件地址不会被公开。 必填项已用*标注

Captcha Code