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

后端 未结 8 1895
暗喜
暗喜 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:00

    Just open your sql file with a text editor and search for 'utf8mb4' and replace with utf8.I hope it would work for you

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

    As some suggested here, replacing utf8mb4 with utf8 will help you resolve the issue. IMHO, I used sed to find and replace them to avoid losing data. In addition, opening a large file into any graphical editor is potential pain. My MySQL data grows up 2 GB. The ultimate command is

    sed 's/utf8mb4_unicode_520_ci/utf8_unicode_ci/g' original-mysql-data.sql > updated-mysql-data.sql
    sed 's/utf8mb4/utf8/g' original-mysql-data.sql > updated-mysql-data.sql
    

    Done!

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

    Open your mysql file any edit tool

    find

    /*!40101 SET NAMES utf8mb4 */;

    change

    /*!40101 SET NAMES utf8 */;

    Save and upload ur mysql.

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

    Your version does not support that character set, I believe it was 5.5.3 that introduced it. You should upgrade your mysql to the version you used to export this file.

    The error is then quite clear: you set a certain character set in your code, but your mysql version does not support it, and therefore does not know about it.

    According to https://dev.mysql.com/doc/refman/5.5/en/charset-unicode-utf8mb4.html :

    utf8mb4 is a superset of utf8

    so maybe there is a chance you can just make it utf8, close your eyes and hope, but that would depend on your data, and I'd not recommend it.

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

    You can try:

    Open sql file by text editor find and replace all

    utf8mb4 to utf8
    

    Import again.

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

    This can help:

    mysqldump --compatible=mysql40 -u user -p DB > dumpfile.sql
    

    PHPMyAdmin has the same MySQL compatibility mode in the 'expert' export options. Although that has on occasions done nothing.

    If you don't have access via the command line or via PHPMyAdmin then editing the

    /*!50003 SET character_set_client  = utf8mb4 */ ; 
    

    bit to read 'utf8' only, is the way to go.

    0 讨论(0)
提交回复
热议问题