[ERROR handle] Configuring MySQL encoding under Linux

Source: Internet
Author: User

MySQL's default encoding is Latin1, the support for Chinese characters is not good, need to edit the configuration file, set the default MySQL code.
This process is a lot of online tutorials, we can refer to
MySQL Modify encoding format

MySQL modify encoding settings and garbled problems

MySQL Configuration modification under Linux

I met several pits on the way, it was disgusting.

    1. Pit 1, my.cnf file not found
      The tutorial says that the path to the MySQL configuration file under Linux is/etc/my.cnf, but cannot be found.
      Baidu a bit, said it is possible to appear this situation. If you have experience, you can write one yourself. But I have no experience.
      Under console input "Find/-name my*.cnf", there are several. This should be an example provided by MySQL.

      Randomly selected a my-small.cnf, according to the tutorial added a few lines to set the code of the statement, put under/ETC/MY.CNF
      Console input "service MySQL restart", restart MySQL

    2. Pit 2, server restart failed
      After entering the restart command, the error

      Removing the my.cnf file can restart normally, possibly MY.CNF syntax.
      view MySQL logs , console input "Vim/usr/local/mysql/data/iz28bvt8qj9z.err"
      Lock the log content based on the time of the operation and see a line of information:

      Internet search, MYSQL5.5 modified character set error: Unknown variable ' Default-character-set=utf8 '
      Comment out the "default-character-set = UTF8" in one line of the configuration file [mysqld] and replace it with "character_set_server = UTF8" .
      Restart, problem solving

The final my.cnf content is as follows, originally MySQL provides a lot of content, was I in the process of dubug in a breath deleted. It's convenient if you have a friend who has the same problem.

[mysql]default-character-set = utf8[mysqld]#default-character-set = utf8character_set_server = utf8[mysql.server]default-character-set = utf8[mysqld_safe]default-character-set = utf8[client]default-character-set = utf8

[ERROR handle] Configuring MySQL encoding under Linux

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.