2

How can I change the collation of AsyncMysqlClient (or AsyncMysqlConnection, I am not sure which one of them) to utf8?

I read the documentation, but I cannot find any method for changing the charset. I am probably missing it, if it's actually there.

Victor
  • 13,914
  • 19
  • 78
  • 147

2 Answers2

1

Think you have to try to change the charset on the connection you get via AsyncMysqlClient->connect?

Kordi
  • 2,405
  • 1
  • 14
  • 13
1

For some reason, we don't actually expose a way to set the encoding of an async connection in the API. It would technically be possible to use AsyncMysqlClient::adoptConnection to create the connection via MySQLi and set the encoding before passing it to the async system, but I wouldn't recommend doing it that way.

Instead, as suggested here, you could set the encoding of the connection explicitly via SQL with:

SET collation_connection = utf8mb4_unicode_ci;
SET NAMES utf8;

If you have access to the configuration of the MySQL server itself, you can use init_connect to have the statements run at the start of every, non-root, connection:

[mysqld]
init_connect='SET collation_connection = utf8mb4_unicode_ci; SET NAMES utf8;'
default-character-set=utf8
character-set-server=utf8
collation-server=utf8mb4_unicode_ci
Orvid King
  • 1,188
  • 10
  • 16
  • For some reason, setting those commands in the server configuration does not bring success. However I managed to get this done by passing those statements as queries on each connection's open – Victor May 31 '16 at 08:15