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