typecho1.2版本已经支持了,无需多余操作,初始安装时数据库选择utf8mb格式

之前发文章和评论时,发现自己的博客不支持 email 表情,还会出现混乱。😁


处理方式:

  1. 把数据库字符修改为 utf8mb_unicode_ci

在 phpmyadmin 面板直接执行命令

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;
  1. 修改数据库的配置文件

网站根目录数据库配置文件 config.inc.php,大约在 60 行

/** 定义数据库参数 */
$db = new Typecho_Db('Pdo_Mysql', 'typecho_');
$db->addServer(array (
  ...
  'charset' => 'utf8mb4',  // 将原来的utf8修改为 utf8mb4
  ...
), Typecho_Db::READ | Typecho_Db::WRITE);
Typecho_Db::set($db);