Skip to content

Instantly share code, notes, and snippets.

@saade
Created September 13, 2018 20:19
Show Gist options
  • Select an option

  • Save saade/85a811ea2f09899f475a0f80068a9f5e to your computer and use it in GitHub Desktop.

Select an option

Save saade/85a811ea2f09899f475a0f80068a9f5e to your computer and use it in GitHub Desktop.
Make mysql accept emoji
# For each database:
ALTER DATABASE database_name CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci;
# For each table:
ALTER TABLE table_name CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
# For each column:
ALTER TABLE table_name CHANGE column_name column_name VARCHAR(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
# (Don’t blindly copy-paste this! The exact statement depends on the column type, maximum length, and other properties. The above line is just an example for a `VARCHAR` column.)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment