<div id="docs-body">
 <div class="chapter">
  <div class="titlepage">
   <div>
    <div>
     <h1 class="title">
      <a name="charset">
      </a>
      Chapter 12 Character Sets, Collations, Unicode
     </h1>
    </div>
   </div>
  </div>
  <div class="toc">
   <p>
    <b>
     Table of Contents
    </b>
   </p>
   <dl class="toc">
    <dt>
     <span class="section">
      <a href="charset-general.html">
       12.1 Character Sets and Collations in General
      </a>
     </span>
    </dt>
    <dt>
     <span class="section">
      <a href="charset-mysql.html">
       12.2 Character Sets and Collations in MySQL
      </a>
     </span>
    </dt>
    <dd>
     <dl>
      <dt>
       <span class="section">
        <a href="charset-repertoire.html">
         12.2.1 Character Set Repertoire
        </a>
       </span>
      </dt>
      <dt>
       <span class="section">
        <a href="charset-metadata.html">
         12.2.2 UTF-8 for Metadata
        </a>
       </span>
      </dt>
     </dl>
    </dd>
    <dt>
     <span class="section">
      <a href="charset-syntax.html">
       12.3 Specifying Character Sets and Collations
      </a>
     </span>
    </dt>
    <dd>
     <dl>
      <dt>
       <span class="section">
        <a href="charset-collation-names.html">
         12.3.1 Collation Naming Conventions
        </a>
       </span>
      </dt>
      <dt>
       <span class="section">
        <a href="charset-server.html">
         12.3.2 Server Character Set and Collation
        </a>
       </span>
      </dt>
      <dt>
       <span class="section">
        <a href="charset-database.html">
         12.3.3 Database Character Set and Collation
        </a>
       </span>
      </dt>
      <dt>
       <span class="section">
        <a href="charset-table.html">
         12.3.4 Table Character Set and Collation
        </a>
       </span>
      </dt>
      <dt>
       <span class="section">
        <a href="charset-column.html">
         12.3.5 Column Character Set and Collation
        </a>
       </span>
      </dt>
      <dt>
       <span class="section">
        <a href="charset-literal.html">
         12.3.6 Character String Literal Character Set and Collation
        </a>
       </span>
      </dt>
      <dt>
       <span class="section">
        <a href="charset-national.html">
         12.3.7 The National Character Set
        </a>
       </span>
      </dt>
      <dt>
       <span class="section">
        <a href="charset-introducer.html">
         12.3.8 Character Set Introducers
        </a>
       </span>
      </dt>
      <dt>
       <span class="section">
        <a href="charset-examples.html">
         12.3.9 Examples of Character Set and Collation Assignment
        </a>
       </span>
      </dt>
      <dt>
       <span class="section">
        <a href="charset-compatibility.html">
         12.3.10 Compatibility with Other DBMSs
        </a>
       </span>
      </dt>
     </dl>
    </dd>
    <dt>
     <span class="section">
      <a href="charset-connection.html">
       12.4 Connection Character Sets and Collations
      </a>
     </span>
    </dt>
    <dt>
     <span class="section">
      <a href="charset-applications.html">
       12.5 Configuring Application Character Set and Collation
      </a>
     </span>
    </dt>
    <dt>
     <span class="section">
      <a href="charset-errors.html">
       12.6 Error Message Character Set
      </a>
     </span>
    </dt>
    <dt>
     <span class="section">
      <a href="charset-conversion.html">
       12.7 Column Character Set Conversion
      </a>
     </span>
    </dt>
    <dt>
     <span class="section">
      <a href="charset-collations.html">
       12.8 Collation Issues
      </a>
     </span>
    </dt>
    <dd>
     <dl>
      <dt>
       <span class="section">
        <a href="charset-collate.html">
         12.8.1 Using COLLATE in SQL Statements
        </a>
       </span>
      </dt>
      <dt>
       <span class="section">
        <a href="charset-collate-precedence.html">
         12.8.2 COLLATE Clause Precedence
        </a>
       </span>
      </dt>
      <dt>
       <span class="section">
        <a href="charset-collation-compatibility.html">
         12.8.3 Character Set and Collation Compatibility
        </a>
       </span>
      </dt>
      <dt>
       <span class="section">
        <a href="charset-collation-coercibility.html">
         12.8.4 Collation Coercibility in Expressions
        </a>
       </span>
      </dt>
      <dt>
       <span class="section">
        <a href="charset-binary-collations.html">
         12.8.5 The binary Collation Compared to _bin Collations
        </a>
       </span>
      </dt>
      <dt>
       <span class="section">
        <a href="charset-collation-effect.html">
         12.8.6 Examples of the Effect of Collation
        </a>
       </span>
      </dt>
      <dt>
       <span class="section">
        <a href="charset-collation-information-schema.html">
         12.8.7 Using Collation in INFORMATION_SCHEMA Searches
        </a>
       </span>
      </dt>
     </dl>
    </dd>
    <dt>
     <span class="section">
      <a href="charset-unicode.html">
       12.9 Unicode Support
      </a>
     </span>
    </dt>
    <dd>
     <dl>
      <dt>
       <span class="section">
        <a href="charset-unicode-utf8mb4.html">
         12.9.1 The utf8mb4 Character Set (4-Byte UTF-8 Unicode Encoding)
        </a>
       </span>
      </dt>
      <dt>
       <span class="section">
        <a href="charset-unicode-utf8mb3.html">
         12.9.2 The utf8mb3 Character Set (3-Byte UTF-8 Unicode Encoding)
        </a>
       </span>
      </dt>
      <dt>
       <span class="section">
        <a href="charset-unicode-utf8.html">
         12.9.3 The utf8 Character Set (Deprecated alias for utf8mb3)
        </a>
       </span>
      </dt>
      <dt>
       <span class="section">
        <a href="charset-unicode-ucs2.html">
         12.9.4 The ucs2 Character Set (UCS-2 Unicode Encoding)
        </a>
       </span>
      </dt>
      <dt>
       <span class="section">
        <a href="charset-unicode-utf16.html">
         12.9.5 The utf16 Character Set (UTF-16 Unicode Encoding)
        </a>
       </span>
      </dt>
      <dt>
       <span class="section">
        <a href="charset-unicode-utf16le.html">
         12.9.6 The utf16le Character Set (UTF-16LE Unicode Encoding)
        </a>
       </span>
      </dt>
      <dt>
       <span class="section">
        <a href="charset-unicode-utf32.html">
         12.9.7 The utf32 Character Set (UTF-32 Unicode Encoding)
        </a>
       </span>
      </dt>
      <dt>
       <span class="section">
        <a href="charset-unicode-conversion.html">
         12.9.8 Converting Between 3-Byte and 4-Byte Unicode Character Sets
        </a>
       </span>
      </dt>
     </dl>
    </dd>
    <dt>
     <span class="section">
      <a href="charset-charsets.html">
       12.10 Supported Character Sets and Collations
      </a>
     </span>
    </dt>
    <dd>
     <dl>
      <dt>
       <span class="section">
        <a href="charset-unicode-sets.html">
         12.10.1 Unicode Character Sets
        </a>
       </span>
      </dt>
      <dt>
       <span class="section">
        <a href="charset-we-sets.html">
         12.10.2 West European Character Sets
        </a>
       </span>
      </dt>
      <dt>
       <span class="section">
        <a href="charset-ce-sets.html">
         12.10.3 Central European Character Sets
        </a>
       </span>
      </dt>
      <dt>
       <span class="section">
        <a href="charset-se-me-sets.html">
         12.10.4 South European and Middle East Character Sets
        </a>
       </span>
      </dt>
      <dt>
       <span class="section">
        <a href="charset-baltic-sets.html">
         12.10.5 Baltic Character Sets
        </a>
       </span>
      </dt>
      <dt>
       <span class="section">
        <a href="charset-cyrillic-sets.html">
         12.10.6 Cyrillic Character Sets
        </a>
       </span>
      </dt>
      <dt>
       <span class="section">
        <a href="charset-asian-sets.html">
         12.10.7 Asian Character Sets
        </a>
       </span>
      </dt>
      <dt>
       <span class="section">
        <a href="charset-binary-set.html">
         12.10.8 The Binary Character Set
        </a>
       </span>
      </dt>
     </dl>
    </dd>
    <dt>
     <span class="section">
      <a href="charset-restrictions.html">
       12.11 Restrictions on Character Sets
      </a>
     </span>
    </dt>
    <dt>
     <span class="section">
      <a href="error-message-language.html">
       12.12 Setting the Error Message Language
      </a>
     </span>
    </dt>
    <dt>
     <span class="section">
      <a href="adding-character-set.html">
       12.13 Adding a Character Set
      </a>
     </span>
    </dt>
    <dd>
     <dl>
      <dt>
       <span class="section">
        <a href="character-arrays.html">
         12.13.1 Character Definition Arrays
        </a>
       </span>
      </dt>
      <dt>
       <span class="section">
        <a href="string-collating.html">
         12.13.2 String Collating Support for Complex Character Sets
        </a>
       </span>
      </dt>
      <dt>
       <span class="section">
        <a href="multibyte-characters.html">
         12.13.3 Multi-Byte Character Support for Complex Character Sets
        </a>
       </span>
      </dt>
     </dl>
    </dd>
    <dt>
     <span class="section">
      <a href="adding-collation.html">
       12.14 Adding a Collation to a Character Set
      </a>
     </span>
    </dt>
    <dd>
     <dl>
      <dt>
       <span class="section">
        <a href="charset-collation-implementations.html">
         12.14.1 Collation Implementation Types
        </a>
       </span>
      </dt>
      <dt>
       <span class="section">
        <a href="adding-collation-choosing-id.html">
         12.14.2 Choosing a Collation ID
        </a>
       </span>
      </dt>
      <dt>
       <span class="section">
        <a href="adding-collation-simple-8bit.html">
         12.14.3 Adding a Simple Collation to an 8-Bit Character Set
        </a>
       </span>
      </dt>
      <dt>
       <span class="section">
        <a href="adding-collation-unicode-uca.html">
         12.14.4 Adding a UCA Collation to a Unicode Character Set
        </a>
       </span>
      </dt>
     </dl>
    </dd>
    <dt>
     <span class="section">
      <a href="charset-configuration.html">
       12.15 Character Set Configuration
      </a>
     </span>
    </dt>
    <dt>
     <span class="section">
      <a href="locale-support.html">
       12.16 MySQL Server Locale Support
      </a>
     </span>
    </dt>
   </dl>
  </div>
  <a class="indexterm" name="idm46045218193024">
  </a>
  <a class="indexterm" name="idm46045218191952">
  </a>
  <a class="indexterm" name="idm46045218190880">
  </a>
  <a class="indexterm" name="idm46045218189808">
  </a>
  <a class="indexterm" name="idm46045218188736">
  </a>
  <a class="indexterm" name="idm46045218187664">
  </a>
  <p>
   MySQL includes character set support that enables you to store data
    using a variety of character sets and perform comparisons according
    to a variety of collations. The default MySQL server character set
    and collation are
   <code class="literal">
    utf8mb4
   </code>
   and
   <code class="literal">
    utf8mb4_0900_ai_ci
   </code>
   , but you can specify character
    sets at the server, database, table, column, and string literal
    levels. To maximize interoperability and future-proofing of your
    data and applications, we recommend that you use the
   <code class="literal">
    utf8mb4
   </code>
   character set whenever possible.
  </p>
  <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
   <div class="admon-title">
    Note
   </div>
   <p>
    <code class="literal">
     UTF8
    </code>
    is a deprecated synonym for
    <code class="literal">
     utf8mb3
    </code>
    , and you should expect it to be removed
      in a future version of MySQL. Specify
    <code class="literal">
     utfmb3
    </code>
    or
      (preferably)
    <code class="literal">
     utfmb4
    </code>
    instead.
   </p>
  </div>
  <p>
   This chapter discusses the following topics:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      What are character sets and collations?
     </p>
    </li>
    <li class="listitem">
     <p>
      The multiple-level default system for character set assignment.
     </p>
    </li>
    <li class="listitem">
     <p>
      Syntax for specifying character sets and collations.
     </p>
    </li>
    <li class="listitem">
     <p>
      Affected functions and operations.
     </p>
    </li>
    <li class="listitem">
     <p>
      Unicode support.
     </p>
    </li>
    <li class="listitem">
     <p>
      The character sets and collations that are available, with
        notes.
     </p>
    </li>
    <li class="listitem">
     <p>
      Selecting the language for error messages.
     </p>
    </li>
    <li class="listitem">
     <p>
      Selecting the locale for day and month names.
     </p>
    </li>
   </ul>
  </div>
  <p>
   Character set issues affect not only data storage, but also
    communication between client programs and the MySQL server. If you
    want the client program to communicate with the server using a
    character set different from the default, you need to indicate which
    one. For example, to use the
   <code class="literal">
    latin1
   </code>
   Unicode
    character set, issue this statement after connecting to the server:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa47419321"><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">'latin1'</span><span class="token punctuation">;</span></code></pre>
  </div>
  <p>
   For more information about configuring character sets for
    application use and character set-related issues in client/server
    communication, see
   <a class="xref" href="charset-applications.html" title="12.5 Configuring Application Character Set and Collation">
    Section 12.5, “Configuring Application Character Set and Collation”
   </a>
   , and
   <a class="xref" href="charset-connection.html" title="12.4 Connection Character Sets and Collations">
    Section 12.4, “Connection Character Sets and Collations”
   </a>
   .
  </p>
 </div>
 <br/>
</div>
