使Typecho支持Emoji表情

最近写文章的时候用到了emoji,发现报错:Database Query Error

解决办法

1、进入数据库,直接运行下列语句:

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;

2、修改数据库的配置文件

网站根目录数据库配置文件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);

查看原帖

署名 - 非商业性使用 - 禁止演绎 4.0