1.整理数据库编码

  1. 进入 PHPmyadmin选择 Typecho所使用的数据库
  2. 【操作】–>【整理】–>【选择 utf8mb4_unicode_ci

2.运行sql语句修改数据库编码

alter table typecho_comments convert to character set utf8mb4 collate utf8mb4_general_ci;
alter table typecho_contents convert to character set utf8mb4 collate utf8mb4_general_ci;
alter table typecho_fields convert to character set utf8mb4 collate utf8mb4_general_ci;
alter table typecho_metas convert to character set utf8mb4 collate utf8mb4_general_ci;
alter table typecho_options convert to character set utf8mb4 collate utf8mb4_general_ci;
alter table typecho_relationships convert to character set utf8mb4 collate utf8mb4_general_ci;
alter table typecho_users convert to character set utf8mb4 collate utf8mb4_general_ci;

3.修改数据库配置文件

  • 网站根目录数据库配置文件config.inc.php
  • 大概在最后边

    /** 定义数据库参数 */
    $db = new Typecho_Db('Pdo_Mysql', 'typecho_');
    $db->addServer(array (
      ...
      'charset' => 'utf8mb4',  // 修改编码为 utf8mb4
      ...
    ), Typecho_Db::READ | Typecho_Db::WRITE);
    Typecho_Db::set($db);
    
最后修改:2021 年 03 月 12 日 01 : 06 PM