mysql 5.7修改字符集

For the recent version of MySQL,mysql

default-character-set = utf8

causes a problem. It's deprecated I think.sql

As Justin Ball says in "Upgrade to MySQL 5.5.12 and now MySQL won’t start, you should:code

  1. Remove that directive and you should be good.server

  2. Then your configuration file ('/etc/my.cnf' for example) should look like that:ci

    [mysqld]
    collation-server = utf8_unicode_ci
    init-connect='SET NAMES utf8'
    character-set-server = utf8
  3. Restart MySQL.unicode

  4. For making sure, your MySQL is UTF-8, run the following queries in your MySQL prompt:get

    • First query:it

      mysql> show variables like 'char%';

      The output should look like:io

      +--------------------------+---------------------------------+
       | Variable_name            | Value                           |
       +--------------------------+---------------------------------+
       | character_set_client     | utf8                            |
       | character_set_connection | utf8                            |
       | character_set_database   | utf8                            |
       | character_set_filesystem | binary                          |
       | character_set_results    | utf8                            |
       | character_set_server     | utf8                            |
       | character_set_system     | utf8                            |
       | character_sets_dir       | /usr/local/mysql/share/charsets/|
       +--------------------------+---------------------------------+
    • Second query:cli

      mysql> show variables like 'collation%';

      And the query output is:

      +----------------------+-----------------+
       | Variable_name        | Value           |
       +----------------------+-----------------+
       | collation_connection | utf8_general_ci |
       | collation_database   | utf8_unicode_ci |
       | collation_server     | utf8_unicode_ci |
       +----------------------+-----------------+
相關文章
相關標籤/搜索