首页 📡 其他技术

在我搭建博客的时候用到了emoji表情,但是发现报错: Database Query Error,故向大佬询问了解决办法

解决办法

1.进入宝塔面板点击phpMyAdmin并登录

phpMyAdmin1.png

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;

phpMyAdmin2.png

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



文章评论