Mysql Chinese garbled Problem Solution

Source: Internet
Author: User
Tags mysql tutorial

Mysql Chinese garbled characters are a common problem for php jsp beginners. There are many solutions. The following describes how to configure mysql in my. cnf.

Symptom:

A similar error occurs when you insert a Chinese character to mysql tutorial 5.5.

ERROR 1366 (HY000): Incorrect string value: 'xd6xd0xcexc4' for column
Cause:

The character set of Db characterset is set to latin1.

1. Check whether the data is garbled:
Mysql> select * from yourtable;
Check if the code is garbled, that is, when you insert data, the current page encoding method is inconsistent with your mysql encoding method.
2. If the above garbled characters are excluded, that is to say, the database can save Chinese characters normally in the tutorial, you need to check the encoding method displayed on your page.


Solution:

Find the my. ini file under the MYSQL installation directory and modify it:


[Client]

Port = 3306

[Mysql]

Default-character-set = gbk


# SERVER SECTION
#----------------------------------------------------------------------
#
# The following options will be read by the MySQL Server. Make sure that
# You have installed the server correctly (see above) so it reads this
# File.
#
[Mysqld]

# The TCP/IP Port the MySQL Server will listen on
Port = 3306


# Path to installation directory. All paths are usually resolved relative to this.
Basedir = "C:/Program Files/MySQL Server 5.0 /"

# Path to the database root
Datadir = "C:/Program Files/MySQL Server 5.0/Data /"

# The default character set that will 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 will be used when create new tables when
Default-storage-engine = INNODB


See my. cnf

Modifying the default Character Set of mysql is implemented by modifying its configuration file.


The mysql configuration file in windows is my. ini, which is usually in the installation directory (for example, C: Program FilesMySQLMySQL Server 5.0). You can add it directly to this file.

Default-character-set = gbk # Or 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 DATA table

Show table status from tablename like '% countries % ';

3. view the character set of the MySQL DATA column (column.

Show full columns from tablename;

4. view the character sets supported by currently installed MySQL.

Show char set;

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.