Convert MySQL table and columns to UTF-8

MySQL to UTF-8 encoding

Changing to UFT-8 encoding can be a pain when you’re doing it from a GUI like MySQL Workbench.
There’s always an easier way to do it with some basic SQL.

The utf8 in mySQL doesn’t actually create a real UTF8 database. It creates a proprietary subset. Real UTF8 in MySQL is called utf8mb4.

-- convert the data that already exists to the character set utf-8
ALTER TABLE <table> CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
-- change the character set to utf-8
ALTER TABLE <table> DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
-- change specific columns
ALTER TABLE <table> CHANGE <column_name> <column_name> VARCHAR(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

Read the full article here

Author: Mitchel Pawirodinomo

Software Engineer | Pentester | FX Trader

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.