#1115 - Unknown character set: 'utf8mb4'

2019-03-01 04:54发布

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.

When exporting then importing I get the following error!

1115 - Unknown character set: 'utf8mb4'

Can somebody point me in the right direction?

4条回答
冷血范
2楼-- · 2019-03-01 05:45

Sometimes I get similar problems while using HeidiSQL which by default exports in utf8mb4 character encoding. Not all MySQL installations support this encoding and importing such data leads to similar error messages. My workaround then is to export data using phpMyAdmin, which exports in 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 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.

查看更多
时光不老,我们不散
3楼-- · 2019-03-01 05:45

This helped me

ALTER TABLE your_table_name CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;
查看更多
爷、活的狠高调
4楼-- · 2019-03-01 05:54

Open sql file by text editor find and replace all

utf8mb4 to utf8

Import again.

查看更多
该账号已被封号
5楼-- · 2019-03-01 05:56

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.

查看更多
登录 后发表回答