zim32 / mysql.dart

MySQL client for Dart written in Dart
BSD 3-Clause "New" or "Revised" License
67 stars 18 forks source link

MySQLServerException [3988]: Conversion from collation utf8_general_ci into utf8mb4_general_ci impossible for parameter, #33

Closed lhzmrl closed 2 years ago

lhzmrl commented 2 years ago

I am trying to get mysql to support emoji, but I get the above error when I insert data after configuring the server, is this because the client does not support it?  Can you give me some suggestions?  Thank you.

my client config like this:

_pool = MySQLConnectionPool(
      host: "127.0.0.1",
      port: 3306,
      userName: "name",
      password: "password",
      databaseName: "database",
      maxConnections: 16,
      collation: 'utf8mb4_general_ci',
    );
lhzmrl commented 2 years ago

some mysql config in my.cnf like this:

# For emoji support
[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
init_connect='SET NAMES utf8mb4'
lhzmrl commented 2 years ago

also, i see some charset config, will it work if I change it?

// set connection charset
await execute(
    'SET @@collation_connection=$_collation, @@character_set_client=utf8, @@character_set_connection=utf8, @@character_set_results=utf8',
);
zim32 commented 2 years ago

You can try to change this code. Write me if it helps

lhzmrl commented 2 years ago

You can try to change this code. Write me if it helps

Modification is effective, you can consider opening attributes

await execute(
      'SET @@collation_connection=$_collation, @@character_set_client=utf8mb4, @@character_set_connection=utf8mb4, @@character_set_results=utf8mb4',
    );
zim32 commented 2 years ago

Fixed in 0.0.26