<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h3 class="title">
      <a name="charset-unicode-utf8mb3">
      </a>
      12.9.2 The utf8mb3 Character Set (3-Byte UTF-8 Unicode Encoding)
     </h3>
    </div>
   </div>
  </div>
  <a class="indexterm" name="idm46045216663440">
  </a>
  <a class="indexterm" name="idm46045216662400">
  </a>
  <a class="indexterm" name="idm46045216660912">
  </a>
  <p>
   The
   <code class="literal">
    utf8mb3
   </code>
   character set has these
        characteristics:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      Supports BMP characters only (no support for supplementary
            characters)
     </p>
    </li>
    <li class="listitem">
     <p>
      Requires a maximum of three bytes per multibyte character.
     </p>
    </li>
   </ul>
  </div>
  <p>
   Applications that use UTF-8 data but require supplementary
        character support should use
   <code class="literal">
    utf8mb4
   </code>
   rather
        than
   <code class="literal">
    utf8mb3
   </code>
   (see
   <a class="xref" href="charset-unicode-utf8mb4.html" title="12.9.1 The utf8mb4 Character Set (4-Byte UTF-8 Unicode Encoding)">
    Section 12.9.1, “The utf8mb4 Character Set (4-Byte UTF-8 Unicode Encoding)”
   </a>
   ).
  </p>
  <a class="indexterm" name="idm46045216653344">
  </a>
  <a class="indexterm" name="idm46045216652256">
  </a>
  <p>
   Exactly the same set of characters is available in
   <code class="literal">
    utf8mb3
   </code>
   and
   <code class="literal">
    ucs2
   </code>
   . That is,
        they have the same
   <a class="link" href="glossary.html#glos_repertoire" title="repertoire">
    repertoire
   </a>
   .
  </p>
  <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
   <div class="admon-title">
    Note
   </div>
   <p>
    The recommended character set for MySQL is
    <code class="literal">
     utf8mb4
    </code>
    . All new applications should use
    <code class="literal">
     utf8mb4
    </code>
    .
   </p>
   <p>
    The
    <code class="literal">
     utf8mb3
    </code>
    character set is deprecated.
    <code class="literal">
     utf8mb3
    </code>
    remains supported for the lifetimes
          of the MySQL 8.0.x and MySQL 8.4.x LTS release series.
   </p>
   <p>
    Expect
    <code class="literal">
     utf8mb3
    </code>
    to be removed in a future
          major release of MySQL.
   </p>
   <p>
    Since changing character sets can be a complex and
          time-consuming task, you should begin to prepare for this
          change now by using
    <code class="literal">
     utf8mb4
    </code>
    for new
          applications. For guidance in converting existing applications
          which use utfmb3, see
    <a class="xref" href="charset-unicode-conversion.html" title="12.9.8 Converting Between 3-Byte and 4-Byte Unicode Character Sets">
     Section 12.9.8, “Converting Between 3-Byte and 4-Byte Unicode Character Sets”
    </a>
    .
   </p>
  </div>
  <p>
   <code class="literal">
    utf8mb3
   </code>
   can be used in
   <code class="literal">
    CHARACTER
        SET
   </code>
   clauses, and
   <code class="literal">
    utf8mb3_
    <em class="replaceable">
     <code>
      collation_substring
     </code>
    </em>
   </code>
   in
   <code class="literal">
    COLLATE
   </code>
   clauses, where
   <em class="replaceable">
    <code>
     collation_substring
    </code>
   </em>
   is
   <code class="literal">
    bin
   </code>
   ,
   <code class="literal">
    czech_ci
   </code>
   ,
   <code class="literal">
    danish_ci
   </code>
   ,
   <code class="literal">
    esperanto_ci
   </code>
   ,
   <code class="literal">
    estonian_ci
   </code>
   , and so forth. For example:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa16389361"><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-sql"><span class="token keyword">CREATE</span> <span class="token keyword">TABLE</span> t <span class="token punctuation">(</span>s1 <span class="token datatype">CHAR</span><span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token keyword">CHARACTER</span> <span class="token keyword">SET</span> utf8mb3<span class="token punctuation">;</span>
<span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> t <span class="token keyword">WHERE</span> s1 <span class="token keyword">COLLATE</span> utf8mb3_general_ci <span class="token operator">=</span> <span class="token string">'x'</span><span class="token punctuation">;</span>
<span class="token keyword">DECLARE</span> x <span class="token datatype">VARCHAR</span><span class="token punctuation">(</span><span class="token number">5</span><span class="token punctuation">)</span> <span class="token keyword">CHARACTER</span> <span class="token keyword">SET</span> utf8mb3 <span class="token keyword">COLLATE</span> utf8mb3_danish_ci<span class="token punctuation">;</span>
<span class="token keyword">SELECT</span> <span class="token function">CAST</span><span class="token punctuation">(</span><span class="token string">'a'</span> <span class="token keyword">AS</span> <span class="token datatype">CHAR</span> <span class="token keyword">CHARACTER</span> <span class="token keyword">SET</span> utf8mb4<span class="token punctuation">)</span> <span class="token keyword">COLLATE</span> utf8mb4_czech_ci<span class="token punctuation">;</span></code></pre>
  </div>
  <p>
   In statements such as
   <code class="literal">
    SHOW CREATE TABLE
   </code>
   or
   <code class="literal">
    SELECT CHARACTER_SET_NAME FROM
        INFORMATION_SCHEMA.COLUMNS
   </code>
   or
   <code class="literal">
    SELECT
        COLLATION_NAME FROM INFORMATION_SCHEMA.COLUMNS
   </code>
   ,
        character sets or collation names prefixed with
   <code class="literal">
    utf8
   </code>
   or
   <code class="literal">
    utf8_
   </code>
   are
        displayed using
   <code class="literal">
    utf8mb3
   </code>
   or
   <code class="literal">
    utf8mb3_
   </code>
   , respectively.
  </p>
  <p>
   <code class="literal">
    utf8mb3
   </code>
   is also valid (but deprecated) in
        contexts other than
   <code class="literal">
    CHARACTER SET
   </code>
   clauses.
        For example:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa72957781"><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-terminal">mysqld <span class="token constant">--character-set-server</span><span class="token attr-value"><span class="token punctuation">=</span>utf8mb3</span></code></pre>
  </div>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa9248442"><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-sql"><span class="token keyword">SET</span> <span class="token keyword">NAMES</span> <span class="token string">'utf8mb3'</span><span class="token punctuation">;</span> <span class="token comment" spellcheck="true">/* and other SET statements that have similar effect */</span>
<span class="token keyword">SELECT</span> _utf8mb3 <span class="token string">'a'</span><span class="token punctuation">;</span></code></pre>
  </div>
  <p>
   For information about data type storage as it relates to
        multibyte character sets, see
   <a class="xref" href="storage-requirements.html#data-types-storage-reqs-strings" title="String Type Storage Requirements">
    String Type Storage Requirements
   </a>
   .
  </p>
 </div>
 <br/>
</div>
