"Data too long for column" error occurred when inserting a Chinese field in MySQL.

Source: Internet
Author: User

Run a local script from mysql5 to create a database. The "data too long for column" error occurs when a Chinese field is inserted. I checked the Internet and found that most of the multibyte users encountered this situation. Most of the Solutions for Google search are to encode the database using GBK or utf8, but I chose utf8 when installing MySQL. Solution: currently, the database is UTF-8. To insert Chinese characters
Change the encoding in my. ini of mysql5 to GBK, and then insert it into it. If you use the MySQL dos interface, it may be garbled. It doesn't matter, and then close it.
MySQL service, reset the MySQL encoding to utf8, restart the server, and use tools such as navicat to check that the correct encoding is not garbled. This will solve the problem.

 

 

# Client Section
#----------------------------------------------------------------------
#
# The following options will be read by MYSQL client applications.
# Note that only client applications are shipped by MySQL are guaranteed
# To Read this section. If you want your own MYSQL client program
# Honor these values, you need to specify it as an option during
# MYSQL client library initialization.
#
[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 = "D:/program files/MySQL Server 5.0 /"

# Path to the Database Root
Datadir = "D:/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 = utf8

Restart and you will be OK.

 

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.