已解决:修改WordPress地址(URL),导致主页面出现404错误

更多知识,请移步我的小破站:http://hellofriend.top

前几天,出于好奇无意间修改了WordPress的URL地址,没想到却连 WordPress 的仪表盘都出现404错误无法登录。为了解决该问题,在网上搜索了一番,发现绝大部分文章帖子都是说伪静态设置出了问题,试着修改.htaccess文件,设置伪静态规则等等,依旧无果…后来猛然发现是数据库的问题。

误操作

误操作

解决方案

1. 使用SSH登录服务器,如XShell等工具都可以
2. 登录到MySQL数据库

输入如下指令,输入密码,进入MySQL数据库。

[root@host ~]# mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1914
Server version: 5.5.62-log Source distribution

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.
3. 查看自己的WordPress是哪个数据库
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sql120_78_215_1    |
| test               |
+--------------------+
5 rows in set (0.00 sec)
4. 选中WordPress的数据库

此处根据自己的情况选择,我的WordPress使用的是 sql120_78_215_1这个数据库。

mysql> USE sql120_78_215_1;
Database changed
5. 查看wp_contens表单
mysql> select * from wp_options limit 1;
+-----------+-------------+------------------------+----------+
| option_id | option_name | option_value           | autoload |
+-----------+-------------+------------------------+----------+
|         1 | siteurl     | http://120.78.215.170 | yes      |
+-----------+-------------+------------------------+----------+
1 row in set (0.00 sec)

可以看到option_value这个属性值,如果WordPress地址(URL)被错误修改,这个option_value就会变成那个错误的地址,并且无法再从后台更改。我们可以通过在数据库中对齐更改来解决。

6.更改option_value属性值
mysql> UPDATE wp_options SET option_value="http://hellofriend.top WHERE option_name="siteurl";
Query OK, 1 row affected (0.01 sec)
Rows matched: 1  Changed: 1  Warnings: 0

按照上述方法更改完毕后,就可以正常登录主页了。

发布了5 篇原创文章 · 获赞 16 · 访问量 2686

猜你喜欢

转载自blog.csdn.net/qq_34161458/article/details/105259099