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.