简体   繁体   English

#1115-未知字符集:“ utf8mb4”

[英]#1115 - Unknown character set: 'utf8mb4'

I have a local webserver running on my pc to which I use for local development. 我的个人计算机上运行着一个本地网络服务器,用于本地开发。 I'm now at the stage of exporting the database and importing onto my hosted VPS. 我现在处于导出数据库并将其导入到托管VPS的阶段。

When exporting then importing I get the following error! 导出然后导入时,出现以下错误!

1115 - Unknown character set: 'utf8mb4' 1115-未知字符集:“ utf8mb4”

Can somebody point me in the right direction? 有人可以指出我正确的方向吗?

The error clearly states that you don't have utf8mb4 supported on your stage db server. 该错误清楚地表明,您的舞台数据库服务器上不支持utf8mb4

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 原因 :可能在本地具有MySQL 5.5.3或更高版本,而在舞台/托管VPS上, MySQL服务器版本低于5.5.3

The utf8mb4 character sets was added in MySQL 5.5.3. utf8mb4字符集是在MySQL 5.5.3中添加的。

utf8mb4 was added because of a bug in MySQL's utf8 character set. 由于MySQL的utf8字符集存在错误,因此添加了utf8mb4 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 ). MySQL对utf8字符集的处理仅允许单个代码点最多3个字节,这不足以代表整个Unicode(最大代码点= 0x10FFFF )。 Because they didn't want to potentially break any stuff that relied on this buggy behaviour, utf8mb4 was added. 因为他们不想破坏任何依赖于这种错误行为的东西, utf8mb4添加了utf8mb4 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. 解决方案1 :只需将您的MySQL服务器升级到5.5.3(至少)-下一次,请注意您在本地,阶段和产品上使用的版本必须全部相同。 A suggestion - in present the default character set should be utf8mb4 . 一个建议 -目前默认字符集应为utf8mb4


Solution 2 (not recommended): Convert the current character set to utf8 , and then export the data - it'll load ok. 解决方案2 (不推荐):将当前字符集转换为utf8 ,然后导出数据-加载成功。

Sometimes I get similar problems while using HeidiSQL which by default exports in utf8mb4 character encoding. 有时我在使用HeidiSQL时会遇到类似的问题,默认情况下,它以utf8mb4字符编码导出。 Not all MySQL installations support this encoding and importing such data leads to similar error messages. 并非所有的MySQL安装都支持这种编码,并且导入此类数据会导致类似的错误消息。 My workaround then is to export data using phpMyAdmin, which exports in utf8. 然后,我的解决方法是使用phpMyAdmin导出数据,该文件在utf8中导出。 There are problably other tools and possible ways like manually editing dump file, converting it from utf8mb4 to utf8 (if needed) and changing SET NAMES utf8mb4 to SET NAMES utf8 . 可能还有其他工具和可能的方式,例如手动编辑转储文件,将其从utf8mb4转换为utf8(如果需要)并将SET NAMES utf8mb4更改为SET NAMES utf8 Utf8mb4 is a superset of utf8, so if you're absolutely sure, that your data is just utf8, then you can simply change SET NAMES in dump file to utf8 . utf8mb4是utf8的超集,因此,如果您完全确定自己的数据只是utf8,则只需将转储文件中的SET NAMES更改为utf8

Open sql file by text editor find and replace all 通过文本编辑器打开sql文件,查找并替换所有

utf8mb4 to utf8

Import again. 再次导入。

这对我有帮助

ALTER TABLE your_table_name CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM