Illegal mix of collations (latin1_swedish_ci,implicit) and (Utf8_general_ci,coer) solutions

Source: Internet
Author: User
Tags create database

In the process of inserting Chinese into MySQL, the system complains:

Illegal mix of collations (latin1_swedish_ci,implicit) and (Utf8_general_ci,coer)

This is because the MySQL default encoding format is not the same as the data stored in the format, the solution:

Open MySQL installation directory, which has a My.ini file, open this file, there are two sets of character sets, the default is Latin (latin1), suggest you want to change, such as: UTF8 or GBK

Open My.ini Find these two places to modify: (If you want to show the Chinese proposal to change into GBK, I tried to modify into a utf8, the results in the MySQL Chinese or display garbled, changed to GBK after the display is normal)

[MySQL]

Default-character-set=gbk

...

# The default character set that'll be used when a new schema or table is

# created and no character set is defined

Default-character-set=gbk

After you have modified it, restart the MySQL service, and then delete the library that you created before, recreate the new libraries and tables (Specify the encoding when creating the library: Create DATABASE dbname default CharSet GBK (if you have already set the new encoding format in the My.ini file, " Default CharSet GBK "can be done without writing"), and you can then view the encoded format of the library mysql>:show create database dbname; and view the table's encoding format: mysql>:show Create Ta BLE tablename

If you do not want to rebuild the library without rebuilding the table, you can modify the encoding format of the libraries and tables that you have already created.

How to modify:

2. Modify the encoding of the library: ALTER DATABASE dbname DEFAULT CHARACTER set GBK 3. To modify the encoding of the table: ALTER TABLE ' TestTable ' DEFAULT CHARACTER SET GBK 4. Modify Word The encoding of the segment:
ALTER TABLE ' tablename ' change ' name ' VARCHAR CHARACTER SET GBK
is to change the field encoding of "name" in the MySQL database tablename table to be GBK in addition to ensure that the data encoding format passed in on the page is consistent with the encoding format in the database.


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.