MySQL import or export database character encoding set settings

Source: Internet
Author: User
Tags character set mysql import

Workaround:

Start--> run-->cmd--> into the DOS command form: (if the command cannot be executed, place the MySQL installation path at the front of the system variable path)

1. Character set settings for fields in a database table. Show CREATE TABLE tablename or show full columns from TableName

The code is as follows Copy Code

Mysql> Show CREATE table T1;
+ ——-+ ————————————
| Table | Create Table
+ ——-+ ————————————
| T1 | CREATE TABLE ' T1 ' (
' id ' int (one) not NULL,
' C1 ' varchar DEFAULT NULL,
PRIMARY KEY (' id ')
) Engine=myisam DEFAULT CHARSET=GBK |
+ ——-+ ————————————
1 row in Set (0.00 sec)

Mysql> show full columns from T1;
+ ——-+ ————-+ —————-+--+-–+-
| Field | Type | Collation | Null | Key |
+ ——-+ ————-+ —————-+--+-–+-
| ID | Int (11) | NULL | NO | PRI |
| C1 | varchar (30) | Gbk_chinese_ci |     YES | |
+ ——-+ ————-+ —————-+--+-–+-
2 rows in Set (0.00 sec)
Mysql>

2. Current connection system parameters show variables like ' char% '

  code is as follows copy code

mysql> show variables like ' char% ';
+ ———————— –+ —————-
| variable_name            | Value
+ ———————— –+ —————-
| character_set_client     | GBK
| character_set_connection | GBK
| character_set_database   | latin1
| character_set_filesystem | binary
| character_set_ results    | GBK
| character_set_server     | latin1
| character_set_system     | UTF8
| character_sets_dir       | C:Program File
+ ———————— –+ —————-
8 rows in Set (0.00 sec)
Mysql>

1. In Chinese, make sure that the character set for this field in the table is Chinese compatible:

Big5 | Big5 Traditional Chinese
gb2312 | GB2312 Simplified Chinese
GBK | GBK Simplified Chinese
UTF8 | UTF-8 Unicode

MySQL Export command:

The code is as follows Copy Code

1.mysqldump-hlocalhost-p3306-uroot-p123456--default-character-set=gb2312 Mysql>f:/pushingdb.sql

MySQL Import command:

The code is as follows Copy Code
1.mysql-uroot-p123456--default-character-set=gb2312 Test<f:/pushingdb.sql

Note: Root is the database username, 123456 is the database password, MySQL is the database name, F:/pushingdb.sql indicates the location of the export to the local;


If you modify the MySQL character set directly, we just need to use the MySQL command in the command

  code is as follows copy code

mysql> SET character_set_client = UTF8;

mysql> SET character_set_connection = UTF8;

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.