Any way to disable charset-handshake and change default server charset in Managed MySQL?

August 21, 2019 192 views
DigitalOcean Databases MySQL PHP PHP Frameworks

Too many old products can’t connect to new MySQL8.
All recommendations or rewrite old product, or change MySQL server settings like this:

[client]
default-character-set=utf8

[mysql]
default-character-set=utf8

[mysqld]
skip-character-set-client-handshake
character-set-client-handshake = 0
collation-server = utf8_unicode_ci
character-set-server = utf8
default_authentication_plugin = mysql_native_password

But how to do it in Managed MySQL?
Also “SET GLOBAL” way currently not available.

1 Answer

Hello!

To preserve the stability of the database cluster, users are not able to modify global variables. However, you can make this change on a database by database basis, as described here:

https://dev.mysql.com/doc/refman/8.0/en/charset-database.html

Here’s an example:
ALTER DATABASE database_name CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

Note however that this will just change the default charset for the database, all existing tables will have to be converted. You can do that with a command such as this one:

ALTER TABLE table_name CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

Hope it helps!

  • Changing database charset didn’t help to connect to server if client don’t support server charset.

Have another answer? Share your knowledge.