{"id":3457,"date":"2017-03-23T18:42:51","date_gmt":"2017-03-23T17:42:51","guid":{"rendered":"https:\/\/florianbrinkmann.com\/en\/?p=3457"},"modified":"2020-02-09T10:59:54","modified_gmt":"2020-02-09T09:59:54","slug":"switch-wordpress-from-utf8-to-utf8mb4-retrospectively","status":"publish","type":"post","link":"https:\/\/florianbrinkmann.com\/en\/switch-wordpress-from-utf8-to-utf8mb4-retrospectively-3457\/","title":{"rendered":"Switch WordPress from utf8 to utf8mb4 retrospectively"},"content":{"rendered":"\n<p>The WordPress 4.2 upgrade changed the database character set from <code class=\"lang-markup\">utf8<\/code> to <code class=\"lang-markup\">utf8mb4<\/code> (for example necessary for full emoji support) if a few requirements were met. This article shows you how to make the switch manually if you did not meet the requirements at the time of the WordPress 4.2 upgrade.<\/p>\n\n\n\n<!--more-->\n\n\n\n<h2 class=\"wp-block-heading\">Requirements for the <code class=\"lang-markup\">utf8mb4<\/code> update<\/h2>\n\n\n\n<p><a href=\"https:\/\/make.wordpress.org\/core\/2015\/04\/02\/the-utf8mb4-upgrade\/\">Gary Pendergast lists the following requirements in his post \u00bbThe utf8mb4 Upgrade\u00ab<\/a> (quoted from his post):<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>You\u2019re currently using the <code class=\"lang-markup\">utf8<\/code> character set.<\/li><li>Your MySQL server is version 5.5.3 or higher (including all 10.x versions of MariaDB).<\/li><li>Your MySQL client libraries are version 5.5.3 or higher. If you\u2019re using <code class=\"lang-markup\">mysqlnd<\/code>, 5.0.9 or higher.<\/li><\/ul>\n\n\n\n<p>Because my hosting provider Uberspace currently uses CentOS 6, which cannot reach the needed MySQL version, I did not get the update automatically with 4.2. After failing with saving an Emoji today, and getting the hint with <code class=\"lang-markup\">utf8mb4<\/code> from <a href=\"https:\/\/twitter.com\/2ndKauBoy\">Bernhard Kau<\/a>, I searched for a solution. <a href=\"http:\/\/blog.crusy.net\/utf8mb4-auf-uberspace\/\">I found it in the post \u00bbutf8mb4 auf uberspace\u00ab on crusy.net \u2014 the solution for me is switching to MariaDB<\/a>.<\/p>\n\n\n\n<p>If you now simply have a MySQL version which is high enough, you can likely change the character set via phpMyAdmin or similar tools (but I did not test that, because that would currently be no solution for me because of the above-named reason).<\/p>\n\n\n\n<p>In any case, you need to change the tables to <code class=\"lang-markup\">utf8mb4<\/code> after that \u2014 changing the database character set is not sufficient.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Changing the tables to <code class=\"lang-markup\">utf8mb4<\/code><\/h2>\n\n\n\n<p><a href=\"http:\/\/wordpress.stackexchange.com\/questions\/195046\/relaunch-4-2-utf8mb4-databse-upgrade\">I found the solution for this problem on wordpress.stackexchange.com<\/a>. There the update routine from 4.2 (respectively 4.3, since the core team of WordPress pushed the routine to 4.3, to get more sites updated) is put into a plugin or <code class=\"lang-markup\">functions.php<\/code> of your theme and called via the URL parameter <code class=\"lang-markup\">?update-utf8bm4=1<\/code>. With that, all tables are switched to <code class=\"lang-markup\">utf8mb4<\/code>, where possible.<\/p>\n\n\n\n<p><a href=\"https:\/\/gist.github.com\/FlorianBrinkmann\/c3f57dd7c26328d7b4de04e696091eee\">I inserted that into a small plugin, which you can find as a Gist on GitHub<\/a>. On a multisite, you have to call the script on each site of the multisite. <strong>If you are done with the change, you should remove the plugin!<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>The WordPress 4.2 upgrade changed the database character set from utf8 to utf8mb4 (for example necessary for full emoji support) if a few requirements were met. This article shows you how to make the switch manually if you did not meet the requirements at the time of the WordPress 4.2 upgrade.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"wpf_show_in_dewp_planet_feed":false,"flobn_post_versions":"","webmentions_disabled_pings":false,"webmentions_disabled":false,"lazy_load_responsive_images_disabled":false,"footnotes":""},"categories":[37],"tags":[],"class_list":["post-3457","post","type-post","status-publish","format-standard","hentry","category-wordpress"],"wp-worthy-pixel":{"ignored":false,"public":"3238f466d3644201b237c935d3ed3be2","server":"vg07.met.vgwort.de","url":"https:\/\/vg07.met.vgwort.de\/na\/3238f466d3644201b237c935d3ed3be2"},"wp-worthy-type":"normal","_links":{"self":[{"href":"https:\/\/florianbrinkmann.com\/en\/wp-json\/wp\/v2\/posts\/3457","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/florianbrinkmann.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/florianbrinkmann.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/florianbrinkmann.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/florianbrinkmann.com\/en\/wp-json\/wp\/v2\/comments?post=3457"}],"version-history":[{"count":3,"href":"https:\/\/florianbrinkmann.com\/en\/wp-json\/wp\/v2\/posts\/3457\/revisions"}],"predecessor-version":[{"id":5905,"href":"https:\/\/florianbrinkmann.com\/en\/wp-json\/wp\/v2\/posts\/3457\/revisions\/5905"}],"wp:attachment":[{"href":"https:\/\/florianbrinkmann.com\/en\/wp-json\/wp\/v2\/media?parent=3457"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/florianbrinkmann.com\/en\/wp-json\/wp\/v2\/categories?post=3457"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/florianbrinkmann.com\/en\/wp-json\/wp\/v2\/tags?post=3457"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}