Analysis of MySQL Chinese Table creation Problems

Source: Internet
Author: User

The problem of creating a MySQL Chinese table is indeed a headache. The following is an example to illustrate the problem of creating a MySQL Chinese table. If you have encountered a problem of creating a MySQL Chinese table before, take a look.

Importing and exporting data in a database is the simplest and most necessary function.

For example, when the system is under development on a personal PC, the database has a lot of initialization data. After the system development is complete, you need to export the initialization data from the PC to an SQL script, you only need to import these SQL scripts on the server to complete database initialization.

However, the import of Chinese characters has become a big problem. When importing Chinese characters, the Data always reports an error "Data too long for column XX at row n"

This problem has always plagued me. Because the data volume was small in the past, I didn't need to import the function, so I had to re-initialize it again. I don't know how to initialize the data. It's too much data to reinitialize, but I always think there will be a way to solve this problem. Today I 've been searching for information online for more than half a day, and this problem is basically solved.

To clearly describe this problem, we will explain it in detail as follows:

1. Create a database

Microsoft Windows XP [version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C: \ Documents ents and Settings \ awish> mysql-u root-p
Enter password :*******
Welcome to the MySQL monitor. Commands end with; or \ g.
Your MySQL connection id is 24 to server version: 5.0.27-community-nt

Type 'help; 'or' \ H' for help. Type '\ C' to clear the buffer.

Mysql> create database test;

2. Set the data encoding to utf8.

 
 
  1. Mysql> use test;
  2. Database changed
  3. Mysql> set names utf8; // set the database character set to utf8
  4. Query OK, 0 rows affected (0.00 sec)
  5.  

3. Create a data table

 
 
  1. Mysql> create table person
  2. -> (
  3. -> Id INT (8) not null AUTO_INCREMENT primary key,
  4. -> Name varchar (16) default 'nobody ',
  5. -> Birthday char (19 ),
  6. ->) ENGINE = InnoDB default charset = utf8 // create a data table and set the character set to utf8
  7. ->;
  8. Query OK, 0 rows affected (0.03 sec)

How to copy data from a MySQL table to a new table

Implementation of MySQL multi-Table Deletion

Advantages and disadvantages of MySQL independent tablespace

Restoration of MySQL MyISAM Table Structure

Two Methods for querying the number of table fields in MySQL

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.