Skip to content

Instantly share code, notes, and snippets.

@xeoncross
Last active September 19, 2020 09:34
Show Gist options
  • Save xeoncross/5d85c3f5547ee04d5bd81113a2c8ec4d to your computer and use it in GitHub Desktop.
Save xeoncross/5d85c3f5547ee04d5bd81113a2c8ec4d to your computer and use it in GitHub Desktop.
Make MySQL FULLY support utf8 glyphs including smilie faces and emoji.
[client]
default-character-set = utf8mb4
[mysql]
default-character-set = utf8mb4
[mysqld]
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci
#init_connect='SET collation_connection = utf8mb4_unicode_ci'
#init_connect='SET NAMES utf8mb4'
# If you have trouble with "ERROR 1071 (42000): Specified key was too long; max key length is ____ bytes"
#innodb-large-prefix=true
#skip-character-set-client-handshake
character-set-client-handshake = FALSE
ALTER DATABASE table_name CHARACTER SET utf8mb4;
ALTER TABLE table_name CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
SHOW VARIABLES LIKE 'character\_set\_%';
ALTER TABLE table_name MODIFY COLUMN text_name VARCHAR(140) CHARACTER SET utf8mb4;
REPAIR TABLE table_name;
OPTIMIZE TABLE table_name;
-- $ mysqlcheck -u root -p --auto-repair --optimize --all-databases
@xeoncross
Copy link
Author

xeoncross commented Nov 4, 2016

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