最近写文章的时候用到了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);
亲测成功,感谢!
MySQL 返回:
#1146 - Table 'admin.typecho_comments' doesn't exist
运行的时候显示这个该怎么弄?
可能是你修改了数据表前缀
为啥我弄了半天也不行呢,那些表全改好了,我连数据库都改好了,网站也设置了,浏览器也换了好几个,就是不行