typecho 如何支持emoji

typecho 如何支持emoji

小唐
2022-11-18 / 0 评论 / 219 阅读 / 正在检测是否收录...
温馨提示:
本文最后更新于2023年05月13日,已超过356天没有更新,若内容或图片失效,请留言反馈。

typecho 默认的数据库不支持emoji,所以需要通过一下方式修改数据库的编码。

如果你的数据库不支持emoji,但是在文章编辑中或者主题设置中使用了emoji会导致你的内容丢失!

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

执行上述sql语句来修改表的编码,如果用的是宝塔面板和MySQL数据库,一般有可视化的phpmyadmin界面,可以在phpmyadmin的控制台里面执行上面的语句,如果是服务器可以在服务器上连接mysql后执行。
最后将 Typecho 目录下的config.inc.php 配置文件中数据库定义参数中的 charset 为 utf8mb4:

 $db->addServer(array (
      'host'      =>  localhost, 
      'user'      =>  'root',
      'password'  =>  'root',
      'charset'   =>  'utf8mb4', //修改这一行
      'port'      =>  3306,
      'database'  =>  ''
  ), Typecho_Db::READ | Typecho_Db::WRITE);
0

评论

博主关闭了所有页面的评论,留言评论可通过微信关注公众号:得水小筑