Mysql Export Import Chinese table solution _mysql

Source: Internet
Author: User
In the development process will often use MySQL Export import Chinese table, this article will detail how to use it, need friends can refer to the next
First, for UTF8 export:
(1) Export all tables of the source database:
Copy Code code as follows:

Mysqldump-u root-p password--socket=mysql.sock--default-character-set=utf8--set-charset=utf8--hex-blob--databases database name & Gt Utf8.sql

(2) Modify the SQL file to delete the command to create the database contained in the header of the file
(3) Login target Database
Mysql-uroot-p Password--default-character-set=utf8--socket=mysql.sock-a
Note: The character set login must be specified, and the specified character set is consistent with the character set specified when exporting
(4) Delete the database (if any)
drop database name;
(5) Create the database and save it as a UTF8 storage format and import
Copy Code code as follows:

Create database name Charset=utf8;
Use database name;
SOURCE Utf8.sql;

After this import, the Chinese table may have garbled. So, to use the following method, import the Chinese table.

Second, export import to the Chinese table:
Copy Code code as follows:

#导出
Mysqldump-u root-p password--socket=mysql.sock--default-character-set=gbk--set-charset=gbk--hex-blob database Name Table name 1 Table Name 2 ... > G Bk.sql
#导入 (When you import a table, if the table already exists, you delete and import it first, so you do not have to delete the existing table beforehand)
mysql-uroot-p Password--DEFAULT-CHARACTER-SET=GBK--socket=mysql.sock-a <<eof
Use database name;
SOURCE Gbk.sql
Eof
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.