ERROR 1115 (42000): Unknown character set: 'utf8mb4'

后端 未结 8 1896
暗喜
暗喜 2020-12-02 16:20

I have a MySQL dump, which I tried to restore with:

mysql -u\"username\" -p\"password\" --host=\"127.0.0.1\" mysql_db < mysql_db

However

相关标签:
8条回答
  • 2020-12-02 17:25

    I am answering the question - as I didn't find any of them complete. As nowadays Unknown character set: 'utf8mb4' is quite prevalent as lot of deployments have MySQL less then 5.5.3 (version in which utf8mb4 was added).


    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.

    From SO answer:


    Verification: To verify you can check the current character set and collation for the DB you're importing the dump from - How do I see what character set a MySQL database / table / column is?


    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.

    0 讨论(0)
  • 2020-12-02 17:26

    maybe whole database + tables + fields should have the same charset??!

    i.e.

    CREATE TABLE `politicas` (
      `ID` int(11) NOT NULL AUTO_INCREMENT,
      `Nombre` varchar(250) CHARACTER SET utf8 NOT NULL,
      -------------------------------------^here!!!!!!!!!!!
      PRIMARY KEY (`ID`)
    ) ENGINE=MyISAM AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;
      -------------------------------------------------^here!!!!!!!!!
    
    0 讨论(0)
提交回复
热议问题