How to set character_set_database and collation_database to utf8 in my.ini?

前端 未结 3 1880
眼角桃花
眼角桃花 2020-12-23 02:12

I\'ve googled a lot about this problem. To sum up, this is what my my.ini looks like:

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES 

[cli         


        
3条回答
  •  悲&欢浪女
    2020-12-23 02:59

    How to configure Character Set and Collation.

    For applications that store data using the default MySQL character set and collation (latin1, latin1_swedish_ci), no special configuration should be needed. If applications require data storage using a different character set or collation, you can configure character set information several ways:

    • Specify character settings per database. For example, applications that use one database might require utf8, whereas applications that use another database might require sjis.
    • Specify character settings at server startup. This causes the server to use the given settings for all applications that do not make other arrangements.
    • Specify character settings at configuration time, if you build MySQL from source. This causes the server to use the given settings for all applications, without having to specify them at server startup.

    The examples shown here for your question to set utf8 character set , here also set collation for more helpful(utf8_general_ci collation`).

    Specify character settings per database

      CREATE DATABASE new_db
      DEFAULT CHARACTER SET utf8
      DEFAULT COLLATE utf8_general_ci;
    

    Specify character settings at server startup

    [mysqld]
    character-set-server=utf8
    collation-server=utf8_general_ci
    

    Specify character settings at MySQL configuration time

    shell> cmake . -DDEFAULT_CHARSET=utf8 \
               -DDEFAULT_COLLATION=utf8_general_ci
    

    This May be lengthy answer but there is all way, you can use. Hopeful my answer is helpful for you. for more information http://dev.mysql.com/doc/refman/5.7/en/charset-applications.html

提交回复
热议问题