Search code examples
mysqliutf-8phpmyadminutf8mb4

Change MySQL-Charset from utf8 to utf8mb4 with PHPMyAdmin


When I want to change MySQL-Charset from utf8 (utf8_general_ci) to utf8mb4 (utf8_unicode_ci) with PHPMyAdmin, it is sufficient when I do these things?

  1. Change database collation to "utf8_unicode_ci"
  2. Change tables collation to "utf8_unicodel_ci"
  3. Change every text column to "utf8_unicodel_ci"
  4. Change set_charset in my PHP code to "utf8mb4"

Is this correct or is something missing what to to? Where can occur any problems?


Solution

  • all coalition the same:

    • for database - utf8mb4_unicode_ci
    • table - utf8mb4_unicode_ci
    • columns - utf8mb4_unicode_ci

    if You want avoid feature mistakes with string functions by mix coalition, good also set default coalition for server:

    edit my.cnf (my.ini):
    [mysqld]
    collation-server = utf8mb4_unicode_ci
    init-connect='SET NAMES utf8mb4'
    character-set-server = utf8mb4
    

    because if You create new tables in feature not manual, but for from script - it create all new tables with default for server settings, and string function may stop work properly