How to insert emoji into MYSQL 5.5 and higher using Django ORM

后端 未结 2 487
误落风尘
误落风尘 2021-02-06 07:48

I am trying to insert emoji\'s into a certain filed in my mysql table. I ran alter command and changed the collation to \"utf8mb4_general_ci\"

         


        
相关标签:
2条回答
  • 2021-02-06 08:15
    DATABASES = {
        'default': {
            'ENGINE': 'django.db.backends.mysql',
            ...
            'OPTIONS': {
                        'charset': 'utf8mb4',
                        'use_unicode': True, },
        },
    }
    

    my.cnf:

    [mysqld]
    character-set-server=utf8mb4
    default-collation=utf8mb4_unicode_ci
    
    [client]
    default-character-set=utf8mb4
    
    0 讨论(0)
  • 2021-02-06 08:21

    this save me on MYSQL 8.0.1

    my.cnf

    [client]
    default-character-set = utf8mb4
    
    [mysql]
    default-character-set = utf8mb4
    
    [mysqld]
    character-set-client-handshake = FALSE
    character-set-server = utf8mb4
    collation-server = utf8mb4_unicode_ci
    
    0 讨论(0)
提交回复
热议问题