已解決:修改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

按照上述方法更改完畢後,就可以正常登錄主頁了。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章