MYSQL table errors when writing Chinese characters or assigning values to fields. mysql assigns values.

Source: Internet
Author: User

MYSQL table errors when writing Chinese characters or assigning values to fields. mysql assigns values.

-- When modifying the field value or writing it directly, Chinese characters become garbled. [Note the Database Name and remember to modify it.] -- when the character sequence is incompatible with Chinese characters, it may directly cause garbled characters. It is best to ensure that the database, table, and field (character type) sorting rules are consistent-eg. if no character sorting rule is specified for a temporary table created under a database, the str field value in the temporary table is assigned to another database table when it is used downstream, garbled characters may occur. When no sorting table is specified, the sorting rule of the table is the sorting rule of the database -- 1. database-level SELECT * -- DEFAULT_CHARACTER_SET_NAME DEFAULT_COLLATION_NAME follow column -- utf8 utf8_general_ci FROM information_schema. 'schema' WHERE SCHEMA_NAME = 'addatacenter'; -- 2. table-level SELECT * -- TABLE_COLLATION follow column -- utf8_general_ciFROM information_schema. 'table' tWHERE t. 'table _ scheme' = 'addatacenter' -- 3. field-level SELECT * -- COLLATION_NAME followed column -- utf8_general_ciFROM information_schema. 'columns' AS cWHERE c. 'table _ scheme' = 'addatacenter'


The text in the mysql list is garbled

Jdbc: mysql: // localhost: 3306/db? UseUnicode = true & characterEncoding = utf8 operations will not be messy
Eliminate garbled characters
Add a set names UTF8 clause after mysql_connect to eliminate garbled characters in the UTF8 database. set names gbk is used for GBK databases. The Code is as follows:

$ Mysql_mylink = mysql_connect ($ mysql_host, $ mysql_user, $ mysql_pass );
Mysql_query ("set names 'gbk '");

The database character set is UTF-8.
The connection statement uses this
Mysql_query ("set names 'utf8 '");
Mysql_query ("set character set UTF8 ");
Mysql_query ("SET CHARACTER_SET_RESULTS = utf8 '");
Another way is to change the MYSQL character set if your machine is running, which is generally valid in MYSQL 4 and MYSQL 5.
Reference: Baidu Library

Mysql database displays simple Chinese characters with garbled characters

It is difficult to convert garbled code into a normal one. It is estimated that there is a problem with your database. You should fix it.

1. stop MySQL services in the run window and enter: net stop mysql
② Change the server and client character set to the desired character set: GB2312 or utf8 ......
The specific operation is: open my. ini under the mysql installation directory;
Find default-character-set and change it to the desired character set: GB2312 or utf8 ......, It should be noted that there are two default-character-set, which will be found by pressing ctrl + f at the beginning of the file and entering default;
③ Restart the MySQL server and enter "net start mysql" in the running window.
④ The most important thing is that we have been able to solve the garbled problem here, but the problem is that we still have the garbled problem, this is because the default character set (latin1) is used when the current table is created. In this case, we need to delete the table and then recreate it.

Related Article

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.