Skip to content

Instantly share code, notes, and snippets.

@PatrickSocha
Last active January 13, 2022 12:02
Show Gist options
  • Save PatrickSocha/62c76b0e79fe6ab441ed6970f7007223 to your computer and use it in GitHub Desktop.
Save PatrickSocha/62c76b0e79fe6ab441ed6970f7007223 to your computer and use it in GitHub Desktop.
Setting MySQL to utf8mb4

Update /etc/my.cnf

[client]
port=3306
default-character-set=utf8mb4

[mysql]
default-character-set=utf8mb4

[mysqld]
character-set-server=utf8mb4
collation-server=utf8mb4_bin

Set the database to:

ALTER SCHEMA `<DATABASE>`  DEFAULT COLLATE utf8mb4_bin ;

Check output of the below which should now mention utf8mb4:

show variables like '%colla%';

Run a test intert with a character such as: ć

Also helpful in getting the database to store UTF8 was the following article by Atlassian. While they set up as utf8 which supports 3 bytes per character, we want utf8mb4 which supports 4 bytes per character. So while you probably want utf8, what you actually want to set is utf8mb4 more info.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment