<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h2 class="title">
      <a name="charset-configuration">
      </a>
      12.15 Character Set Configuration
     </h2>
    </div>
   </div>
  </div>
  <p>
   The MySQL server has a compiled-in default character set and
      collation. To change these defaults, use the
   <a class="link" href="server-system-variables.html#sysvar_character_set_server">
    <code class="option">
     --character-set-server
    </code>
   </a>
   and
   <a class="link" href="server-system-variables.html#sysvar_collation_server">
    <code class="option">
     --collation-server
    </code>
   </a>
   options when you
      start the server. See
   <a class="xref" href="server-options.html" title="7.1.7 Server Command Options">
    Section 7.1.7, “Server Command Options”
   </a>
   . The
      collation must be a legal collation for the default character set.
      To determine which collations are available for each character
      set, use the
   <a class="link" href="show-collation.html" title="15.7.7.5 SHOW COLLATION Statement">
    <code class="literal">
     SHOW COLLATION
    </code>
   </a>
   statement or query the
   <code class="literal">
    INFORMATION_SCHEMA
   </code>
   <a class="link" href="information-schema-collations-table.html" title="28.3.6 The INFORMATION_SCHEMA COLLATIONS Table">
    <code class="literal">
     COLLATIONS
    </code>
   </a>
   table.
  </p>
  <p>
   If you try to use a character set that is not compiled into your
      binary, you might run into the following problems:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      If your program uses an incorrect path to determine where the
          character sets are stored (which is typically the
      <code class="filename">
       share/mysql/charsets
      </code>
      or
      <code class="filename">
       share/charsets
      </code>
      directory under the MySQL
          installation directory), this can be fixed by using the
      <code class="option">
       --character-sets-dir
      </code>
      option when you run the
          program. For example, to specify a directory to be used by
          MySQL client programs, list it in the
      <code class="literal">
       [client]
      </code>
      group of your option file. The
          examples given here show what the setting might look like for
          Unix or Windows, respectively:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-ini"><div class="docs-select-all right" id="sa28300049"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-ini"><span class="token selector">[client]</span>
<span class="token constant">character-sets-dir</span><span class="token attr-value"><span class="token punctuation">=</span>/usr/local/mysql/share/mysql/charsets</span>

<span class="token selector">[client]</span>
<span class="token constant">character-sets-dir</span><span class="token attr-value"><span class="token punctuation">=</span>"C:/Program Files/MySQL/MySQL Server 8.4/share/charsets"</span></code></pre>
     </div>
    </li>
    <li class="listitem">
     <p>
      If the character set is a complex character set that cannot be
          loaded dynamically, you must recompile the program with
          support for the character set.
     </p>
     <p>
      For Unicode character sets, you can define collations without
          recompiling by using LDML notation. See
      <a class="xref" href="adding-collation-unicode-uca.html" title="12.14.4 Adding a UCA Collation to a Unicode Character Set">
       Section 12.14.4, “Adding a UCA Collation to a Unicode Character Set”
      </a>
      .
     </p>
    </li>
    <li class="listitem">
     <p>
      If the character set is a dynamic character set, but you do
          not have a configuration file for it, you should install the
          configuration file for the character set from a new MySQL
          distribution.
     </p>
    </li>
    <li class="listitem">
     <p>
      If your character set index file
          (
      <code class="filename">
       Index.xml
      </code>
      ) does not contain the name for
          the character set, your program displays an error message:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-none"><div class="docs-select-all right" id="sa48751358"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-none">Character set '<em class="replaceable">charset_name</em>' is not a compiled character set and is not
specified in the '/usr/share/mysql/charsets/Index.xml' file</code></pre>
     </div>
     <p>
      To solve this problem, you should either get a new index file
          or manually add the name of any missing character sets to the
          current file.
     </p>
    </li>
   </ul>
  </div>
  <p>
   You can force client programs to use specific character set as
      follows:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-ini"><div class="docs-select-all right" id="sa87190508"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-ini"><span class="token selector">[client]</span>
<span class="token constant">default-character-set</span><span class="token attr-value"><span class="token punctuation">=</span><em class="replaceable">charset_name</em></span></code></pre>
  </div>
  <p>
   This is normally unnecessary. However, when
   <a class="link" href="server-system-variables.html#sysvar_character_set_system">
    <code class="literal">
     character_set_system
    </code>
   </a>
   differs from
   <a class="link" href="server-system-variables.html#sysvar_character_set_server">
    <code class="literal">
     character_set_server
    </code>
   </a>
   or
   <a class="link" href="server-system-variables.html#sysvar_character_set_client">
    <code class="literal">
     character_set_client
    </code>
   </a>
   , and you
      input characters manually (as database object identifiers, column
      values, or both), these may be displayed incorrectly in output
      from the client or the output itself may be formatted incorrectly.
      In such cases, starting the mysql client with
   <a class="link" href="mysql-command-options.html#option_mysql_default-character-set">
    <code class="option">
     --default-character-set=
     <em class="replaceable">
      <code>
       system_character_set
      </code>
     </em>
    </code>
   </a>
   —that
      is, setting the client character set to match the system character
      set—should fix the problem.
  </p>
 </div>
 <br/>
</div>
