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:
- CREATE TABLE Q3_City
- (
- city_id INTEGER NOT NULL,
- name VARCHAR(64) NOT NULL,
- region_id INTEGER NOT NULL,
- user_id INTEGER NOT NULL
- )
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.
- default-character-set=utf8
- default-storage-engine=MyISAM
- default-collation=utf8_bin
- 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.
- ./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