{"id":9193,"date":"2026-06-01T02:48:21","date_gmt":"2026-06-01T00:48:21","guid":{"rendered":"https:\/\/mybox.com\/help\/?post_type=manual_kb&#038;p=9193"},"modified":"2026-06-01T02:48:22","modified_gmt":"2026-06-01T00:48:22","slug":"how-to-change-the-encoding-of-a-mysql-database","status":"publish","type":"manual_kb","link":"https:\/\/mybox.com\/help\/en\/knowledgebase\/how-to-change-the-encoding-of-a-mysql-database\/","title":{"rendered":"How to change the encoding of a MySQL database?"},"content":{"rendered":"\n<div class=\"translation-block translation-block-merged\">\n<p class=\"wp-block-paragraph\">The character encoding of a MySQL database determines how text data is stored and interpreted. Using the correct encoding is important for proper display of special characters, diacritics, and multilingual content.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Before making any changes, it is strongly recommended to create a full database backup.<\/p>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_86 ez-toc-wrap-left counter-hierarchy ez-toc-counter ez-toc-custom ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/mybox.com\/help\/en\/knowledgebase\/how-to-change-the-encoding-of-a-mysql-database\/#Changing_the_database_encoding\" >Changing the database encoding<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/mybox.com\/help\/en\/knowledgebase\/how-to-change-the-encoding-of-a-mysql-database\/#Important_considerations\" >Important considerations<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/mybox.com\/help\/en\/knowledgebase\/how-to-change-the-encoding-of-a-mysql-database\/#Creating_a_backup_before_changes\" >Creating a backup before changes<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/mybox.com\/help\/en\/knowledgebase\/how-to-change-the-encoding-of-a-mysql-database\/#Importing_data_with_a_specific_encoding\" >Importing data with a specific encoding<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/mybox.com\/help\/en\/knowledgebase\/how-to-change-the-encoding-of-a-mysql-database\/#Best_practices\" >Best practices<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/mybox.com\/help\/en\/knowledgebase\/how-to-change-the-encoding-of-a-mysql-database\/#Summary\" >Summary<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Changing_the_database_encoding\"><\/span>Changing the database encoding<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<\/div>\n\n<div id=\"mybox-1916051043\" class=\"mybox-content mybox-entity-placement\"><div class=\"early-access-banner-inpost\">\r\n  <div class=\"banner-left-inpost\">\r\n    <div class=\"icon-box-inpost\">\r\n      <img decoding=\"async\" src=\"https:\/\/mybox.com\/help\/wp-content\/uploads\/2026\/02\/square-info-icon.svg\" alt=\"Info\">\r\n    <\/div>\r\n    <div class=\"text-box-inpost\">\r\n      <span class=\"label-inpost\"><span class=\"translation-block translation-block-banner-text\">Early access<\/span><\/span>\r\n      <h4><span class=\"translation-block translation-block-banner-text\">Still need help?<\/span><\/h4>\r\n      <p><span class=\"translation-block translation-block-banner-text\">Contact our customer service team.<\/span><\/p>\r\n    <\/div>\r\n  <\/div>\r\n\r\n  <div class=\"banner-right-inpost\">\r\n    <a href=\"https:\/\/panel.mybox.com\/helpdesk2\/v\/list\/\" class=\"banner-button-inpost\"><span class=\"translation-block translation-block-banner-text\">Message us<\/span><\/a>\r\n  <\/div>\r\n<\/div><\/div>\n\n<div class=\"translation-block translation-block-merged\"><p class=\"wp-block-paragraph\">To change the character set of an existing database, you can use the <code>ALTER DATABASE<\/code> command.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ALTER DATABASE database_name\nCHARACTER SET utf8mb4\nCOLLATE utf8mb4_unicode_ci;\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Where:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>database_name<\/code> \u2013 the name of the database<\/li>\n\n\n\n<li><code>utf8mb4<\/code> \u2013 the character set to be used<\/li>\n\n\n\n<li><code>utf8mb4_unicode_ci<\/code> \u2013 the collation associated with the selected character set<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">The <code>utf8mb4<\/code> character set is generally recommended because it supports the full range of Unicode characters.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Important_considerations\"><\/span>Important considerations<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Changing the default encoding of a database does not automatically convert the encoding of existing tables and columns.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In some cases, additional commands may be required to update:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>existing tables<\/li>\n\n\n\n<li>column definitions<\/li>\n\n\n\n<li>imported data<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Failure to perform a complete conversion may result in incorrectly displayed characters.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Creating_a_backup_before_changes\"><\/span>Creating a backup before changes<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Before modifying the encoding, create a backup of your database:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mysqldump -u username -p database_name &gt; backup.sql\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This allows you to restore your data if any issues occur during the conversion process.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Importing_data_with_a_specific_encoding\"><\/span>Importing data with a specific encoding<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">When restoring a database, you can specify the character set during import:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mysql -u username -p --default-character-set=utf8mb4 database_name &lt; backup.sql\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Replace:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>username<\/code> with your MySQL user<\/li>\n\n\n\n<li><code>database_name<\/code> with the target database name<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Best_practices\"><\/span>Best practices<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Before changing the encoding:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>create a complete backup<\/li>\n\n\n\n<li>verify the current database encoding<\/li>\n\n\n\n<li>check the encoding of tables and columns<\/li>\n\n\n\n<li>test the conversion on a development copy if possible<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">This helps prevent data corruption and character display issues.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Summary\"><\/span>Summary<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">You can change a MySQL database&#8217;s default encoding using the <code>ALTER DATABASE<\/code> command. Before making any changes, create a backup and verify that tables and columns are also configured correctly. For most modern applications, the <code>utf8mb4<\/code> character set is the recommended choice.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"template":"","format":"standard","manualknowledgebasecat":[9],"manual_kb_tag":[5851,5852,2153,5844,5845,5846,5847,5848,5849,5850],"class_list":["post-9193","manual_kb","type-manual_kb","status-publish","format-standard","hentry","manualknowledgebasecat-databases","manual_kb_tag-convert-table-encoding","manual_kb_tag-convert-column-encoding","manual_kb_tag-mysql-database","manual_kb_tag-database-encoding","manual_kb_tag-character-encoding","manual_kb_tag-character-set","manual_kb_tag-utf8mb","manual_kb_tag-utf8mb-collation","manual_kb_tag-database-collation","manual_kb_tag-change-database-encoding"],"_links":{"self":[{"href":"https:\/\/mybox.com\/help\/en\/wp-json\/wp\/v2\/manual_kb\/9193","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mybox.com\/help\/en\/wp-json\/wp\/v2\/manual_kb"}],"about":[{"href":"https:\/\/mybox.com\/help\/en\/wp-json\/wp\/v2\/types\/manual_kb"}],"author":[{"embeddable":true,"href":"https:\/\/mybox.com\/help\/en\/wp-json\/wp\/v2\/users\/1"}],"version-history":[{"count":1,"href":"https:\/\/mybox.com\/help\/en\/wp-json\/wp\/v2\/manual_kb\/9193\/revisions"}],"predecessor-version":[{"id":9194,"href":"https:\/\/mybox.com\/help\/en\/wp-json\/wp\/v2\/manual_kb\/9193\/revisions\/9194"}],"wp:attachment":[{"href":"https:\/\/mybox.com\/help\/en\/wp-json\/wp\/v2\/media?parent=9193"}],"wp:term":[{"taxonomy":"manualknowledgebasecat","embeddable":true,"href":"https:\/\/mybox.com\/help\/en\/wp-json\/wp\/v2\/manualknowledgebasecat?post=9193"},{"taxonomy":"manual_kb_tag","embeddable":true,"href":"https:\/\/mybox.com\/help\/en\/wp-json\/wp\/v2\/manual_kb_tag?post=9193"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}