Problem phenomenon:
A similar error occurs when inserting Chinese into MySQL tutorial 5.5
ERROR 1366 (HY000): Incorrect string value: ' Xd6xd0xcexc4 ' for column
Problem Reason:
Db CharacterSet's character set is set to Latin1
1, first determine whether the data is stored in garbled characters:
Mysql>select * from Yourtable;
See if it is garbled, that is, when you insert the data, the current page encoding and your MySQL encoding method is inconsistent.
2, if the exclusion of the above garbled possible, that is, the database tutorial can normally save Chinese, you need to check your page to display the encoding method
Solution:
Locate the My.ini file modifications under the MySQL installation directory:
[Client]
port=3306
[MySQL]
Default-character-set=gbk
# SERVER Section
# ----------------------------------------------------------------------
#
# The following options would be read by the MySQL Server. Make sure that
# You have installed the server correctly (* above) so it reads this
# file.
#
[Mysqld]
# The TCP/IP Port the MySQL Server would listen on
port=3306
#Path to installation directory. All paths are usually resolved relative to this.
Basedir= "C:/Program files/mysql/mysql Server 5.0/"
#Path to the database root
Datadir= "C:/Program files/mysql/mysql Server 5.0/data/"
# 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
# The default storage engine that would be used when create new tables
Default-storage-engine=innodb
Reference my.cnf
Modifying the default character set for MySQL is done by modifying its configuration file
The MySQL configuration file under Windows is My.ini, typically under the installation directory (such as C:Program Filesmysqlmysql Server 5.0), which can be added directly to the file
DEFAULT-CHARACTER-SET=GBK #或gb2312, Big5,utf8
Then restart MySQL
View MySQL database server character set, database character set and client character set
Show variables like '%char% ';
Character_set_client, client Character set
Character_set_database, database Character set
Character_set_server, server character set
2. View the character set of the MySQL Datasheet (table)
Show table status from tablename like '%countries% ';
3. View the character set of the MySQL data Columns (column).
Show full columns from TableName;
4. View the character set supported by the currently installed MySQL.
Show Char set;