8

Wordpress 突然乱码的原因和解决方案 - physixfan

 1 year ago
source link: https://www.physixfan.com/wordpress-turanluanmadeyuanyinhejiejuefangan/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

WordPress 突然乱码的原因和解决方案

作者: physixfan

一觉醒来 我的这个博客突然就变成了这幅乱码画风:

screencapture-physixfan-2022-12-09-22_58_50-645x1024.png

明明我啥都没改啊!怎么会突然就坏掉了呢?而且我其他相似设定、相同服务器的Wordpress博客也没有遇到这个问题啊?

我还想起来以前关注过的另一个博客也变成了这样:

Screenshot-2022-12-09-at-23.04.19-911x1024.png

咨询了一下我们博客服务器的客服,等了一天了他们也没研究出个所以然。

最诡异的问题是,竟然恢复以前的备份也没用,恢复出来的还是乱码!

于是我又请教了我的两位高手朋友wsmlby和skysniper,终于有了思路。在有了思路之后再次联系服务器的客服之后,终于问题得到了解决。

原来乱码是因为数据库的编码和Wordpress的编码不一致所导致的。很久很久以前就建站的Wordpress网站,其数据库用的编码是 “latin1_swedish_ci”,然而现在Wordpress默认的编码都是UTF-8了。不知道是哪一天突然间服务器那边似乎是改了设定,因此如果没有专门指定编码,则老Wordpress网站就遇到这个编码不一致的问题了。新一点的Wordpress网站都没有问题是因为后来Wordpress的数据库也都是UTF-8编码了。

如果你的Wordpress也遇到了同样的乱码问题,那么解决方案很简单:在 config.php 中指定编码为这样即可:

define ('DB_CHARSET', 'latin1');

参考资料:

1 Comment Post a comment
  1. 多年不见更新1次 (~ ̄▽ ̄)~ 哈哈!
    来踩一下!

    Reply

Share your thoughts, post a comment.

Name (required) Email (required) Website Comment

Note: HTML is allowed. Your email address will never be published.

Subscribe to comments


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK