typecho无法输入emoji的问题
这篇文章讲得清楚,也说了怎么解决。总之是mysql的utf-8编码的问题。
不过文章里指定了工具为phpAdmin
,我这儿用的阿里万网,是DMS
,额,好像是阿里自己开发的工具,没有那个“数据库操作-整理-选择 utf8mb4_unicode_ci”的地方。好在还有其他参考:
How can I convert entire MySQL database character-set to UTF-8 and collation to UTF-8?
How to easily convert utf8 tables to utf8mb4 in MySQL 5.5
发现有命令行转数据库和表的方式,如下:
ALTER DATABASE databasename CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
ALTER TABLE tablename CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
准备工作是看一下Php和mysql支持不,php要求版本大于等于5.5
,mysql也是要求大于等于5.5.3
。
哦,看来我这个是不行了。我的mysql居然才5.1.48... 看来还是断了这个念想吧...
mysql>select version();
+---------------------+
| version() |
+---------------------+
| 5.1.48-log |
+---------------------+
共返回 1 行记录,花费 34 ms.
还是介绍一下。
- 先转数据库,每一家名字不一样,自己填database name
ALTER DATABASE databasename CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
- 再转表
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;
* 最后通过ftp改网站根目录数据库配置文件`config.inc.php`
```php
$db->addServer(array (
'host' => localhost,
'user' => 'youruser',
'password' => 'yourpassword',
'charset' => 'utf8mb4', //修改这一行
'port' => 3306,
'database' => 'yourdatabase'
), Typecho_Db::READ | Typecho_Db::WRITE);