Solution to three types of mysql tabulation garbled data

Source: Internet
Author: User

The problem of table creation garbled by mysql is a headache. The following describes how to solve the problem of table creation garbled by mysql for your reference.

The mysql table creation is garbled. The default mysql table creation format is latin,

Method 1: Enter Chinese characters in the table with garbled characters. The following figure shows how to create a table:

 
 
  1. CREATE TABLE Q3_City  
  2. (  
  3. city_id  INTEGER NOT NULL,  
  4. name  VARCHAR(64) NOT NULL,  
  5. region_id  INTEGER NOT NULL,  
  6. user_id  INTEGER NOT NULL  
  7. )  

ENGINE = InnoDB default charset = utf8 COLLATE = utf8_unicode_ci;
The last section adds the encoding format of the table, which is cumbersome.

Method 2: The encoding format is not specified when mysql is installed.
You can add it to the mysqld field of my. cnf.

 
 
  1. default-character-set=utf8 
  2. default-storage-engine=MyISAM 
  3. default-collation=utf8_bin 
  4. init_connect='SET NAMES utf8' 

Method 3: Specify the encoding format when installing mysql (this method is recommended). If 2nd encoding formats are specified, the error message is invalid.

 
 
  1. ./configure --prefix=/usr/local/mysql --enable-assembler --with-mysqld-ldflags=-all-static --with-charset=utf8 

Add the encoding format when compiling mysql, and add new tables to the database in UTF8 format by default.

Three Common MySQL table creation statements

MySQL connection Query

How to Implement MySQL multi-Table insertion

Two tips for MySQL table repair

Restrictions on Functions of MySQL partition tables

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.