1

我在我的电脑上运行了一个本地网络服务器,用于本地开发。我现在正处于导出数据库并导入到我的托管 VPS 的阶段。

导出然后导入时出现以下错误!

1115 - 未知字符集:'utf8mb4'

有人可以指出我正确的方向吗?

4

4 回答 4

4

The error clearly states that you don't have utf8mb4 supported on your stage db server.

Cause: probably locally you have MySQL version 5.5.3 or greater, and on stage/hosted VPS you have MySQL server version less then 5.5.3

The utf8mb4 character sets was added in MySQL 5.5.3.

utf8mb4 was added because of a bug in MySQL's utf8 character set. MySQL's handling of the utf8 character set only allows a maximum of 3 bytes for a single codepoint, which isn't enough to represent the entirety of Unicode (Maximum codepoint = 0x10FFFF). Because they didn't want to potentially break any stuff that relied on this buggy behaviour, utf8mb4 was added. Documentation here.


Solution 1: Simply upgrade your MySQL server to 5.5.3 (at-least) - for next time be conscious about the version you use locally, for stage, and for prod, all must have to be same. A suggestion - in present the default character set should be utf8mb4.


Solution 2 (not recommended): Convert the current character set to utf8, and then export the data - it'll load ok.

于 2016-08-17T11:31:56.903 回答
1

通过文本编辑器打开sql文件查找并替换所有

utf8mb4 to utf8

再次导入。

于 2017-02-22T05:31:11.880 回答
1

有时我在使用 HeidiSQL 时遇到类似的问题,默认情况下以 utf8mb4 字符编码导出。并非所有 MySQL 安装都支持这种编码,并且导入此类数据会导致类似的错误消息。我的解决方法是使用 phpMyAdmin 导出数据,它以 utf8 格式导出。可能还有其他工具和可能的方法,例如手动编辑转储文件,将其从 utf8mb4 转换为 utf8(如果需要)并更改SET NAMES utf8mb4SET NAMES utf8. utf8mb4 是 utf8 的超集,所以如果您绝对确定您的数据只是 utf8,那么您只需将SET NAMES转储文件更改为utf8.

于 2015-10-09T11:57:24.117 回答
1

这对我有帮助

ALTER TABLE your_table_name CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;
于 2017-08-12T05:45:51.760 回答