MySQL code problem resolution record under Mac

Source: Internet
Author: User

With the MySQL time, inexplicable wonderful insertion does not enter the Chinese, although know that must be the problem of coding, but it took a long time to solve it, the record here.

1. Change the encoding of the MySQL program:

MySQL modified the code, linux/mac/unix/Universal modified MySQL encoding needs to use the MYSLQ configuration file, the file in/etc/my.cnf,mac user default is not this file, you can go to the MySQL installation directory/ Support-files find any one my-***.cnf copy to/ect, pay attention to copy over to change the name of my.cnf! Then: add default-character-set = UTF8 under [client] and add the following three lines under [mysqld]: Default-storage-engine = INNODB character-set-server = UTF8 Collation-server = utf8_general_ci above can guarantee the program Utf_8 encoding, but there may still be a problem, can not insert Chinese. 2. Check the encoding of the database, Workbench to Utf-8-general-ci, may not be. 3. Look at the specific data sheet, see the collection property of varchar (), General is latin1, this also modified into utf-8-general-ci, perfect solve the problem.

MySQL code problem resolution record under Mac

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.