{"id":319,"date":"2022-08-05T11:59:38","date_gmt":"2022-08-05T17:59:38","guid":{"rendered":"https:\/\/blog.d5.ca\/?p=319"},"modified":"2026-01-12T15:52:00","modified_gmt":"2026-01-12T22:52:00","slug":"mysql-or-mariadb-and-character-sets-collation","status":"publish","type":"post","link":"https:\/\/blog.d5.ca\/?p=319","title":{"rendered":"MySQL or MariaDB and Character Sets\/Collation"},"content":{"rendered":"\n<p>In MySQL and MariaDB, utf8 is not actually UTF-8 encoding. Always use utf8mb4.<\/p>\n\n\n\n<p>To convert a table to utf8mb4:<\/p>\n\n\n<pre>ALTER TABLE `table_name` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;<\/pre>\n\n\n<p>To show character set and collation variables:<\/p>\n\n\n\n<pre> SHOW VARIABLES WHERE Variable_name LIKE '%collat%' OR Variable_name LIKE '%character%'<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">References:<\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li><a rel=\"noreferrer noopener\" href=\"https:\/\/adamhooper.medium.com\/in-mysql-never-use-utf8-use-utf8mb4-11761243e434\" data-type=\"URL\" data-id=\"https:\/\/adamhooper.medium.com\/in-mysql-never-use-utf8-use-utf8mb4-11761243e434\" target=\"_blank\">https:\/\/adamhooper.medium.com\/in-mysql-never-use-utf8-use-utf8mb4-11761243e434<\/a><\/li><li><a rel=\"noreferrer noopener\" href=\"https:\/\/mathiasbynens.be\/notes\/mysql-utf8mb4#utf8-to-utf8mb4\" target=\"_blank\">https:\/\/mathiasbynens.be\/notes\/mysql-utf8mb4#utf8-to-utf8mb4<\/a><\/li><li><a rel=\"noreferrer noopener\" href=\"https:\/\/database.guide\/set-the-character-set-and-collation-of-a-table-in-mariadb\/\" data-type=\"URL\" data-id=\"https:\/\/database.guide\/set-the-character-set-and-collation-of-a-table-in-mariadb\/\" target=\"_blank\">https:\/\/database.guide\/set-the-character-set-and-collation-of-a-table-in-mariadb\/<\/a><\/li><\/ul>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In MySQL and MariaDB, utf8 is not actually UTF-8 encoding. Always use utf8mb4. To convert a table to utf8mb4: ALTER TABLE `table_name` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; To show character set and collation variables: SHOW VARIABLES WHERE Variable_name LIKE &#8216;%collat%&#8217; OR Variable_name LIKE &#8216;%character%&#8217; References: https:\/\/adamhooper.medium.com\/in-mysql-never-use-utf8-use-utf8mb4-11761243e434 https:\/\/mathiasbynens.be\/notes\/mysql-utf8mb4#utf8-to-utf8mb4 https:\/\/database.guide\/set-the-character-set-and-collation-of-a-table-in-mariadb\/<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":"","_links_to":"","_links_to_target":""},"categories":[1],"tags":[],"class_list":["post-319","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/blog.d5.ca\/index.php?rest_route=\/wp\/v2\/posts\/319","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.d5.ca\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.d5.ca\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.d5.ca\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.d5.ca\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=319"}],"version-history":[{"count":3,"href":"https:\/\/blog.d5.ca\/index.php?rest_route=\/wp\/v2\/posts\/319\/revisions"}],"predecessor-version":[{"id":324,"href":"https:\/\/blog.d5.ca\/index.php?rest_route=\/wp\/v2\/posts\/319\/revisions\/324"}],"wp:attachment":[{"href":"https:\/\/blog.d5.ca\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=319"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.d5.ca\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=319"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.d5.ca\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=319"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}