I am using the circleci/mysql docker image. I have have unsuccessfully tried to set the client default-character-set to utf8mb4. Is there a recommended way to do this, or any tutorials/articles someone could point me to? thanks!
Could you set your database collation to that charset instead? I presume then if you connect via a client, in the absence of a client setting, it will use the database default.
@halfer Prior to posting I tried the following when setting up the mysql container. It doesn’t seem to work though. I’m not sure if I’m doing this incorrectly, or if I should approach it some other way
- image: circleci/mysql:5.7 command: mysqld --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci --innodb-strict-mode=true
Is there a SQL command you can run to get MySQL to output the new default collation?
Why do you say it did not seem to work?
@halfer, I know it’s not working because I’ve run the following command on tables that are created as part of my circleci configuration and the proper character set isn’t reflected.
CREATE TABLE table_name
I also know it’s not working because I have a test that creates a table and inserts data into it. Some of this data are emojis, which needs utf8mb4. Instead of successfully inserting into the table, it errors out. The two ways of configuring a client set for a connection are as follows
- using SET NAMES ‘utf8mb4’; after the client has connected to the MySQL server
- Edit the default-character-set for the client in your .my.cnf
I have also tried editing the mysqld my.cnf in circleci but it doesn’t do anything.