Mysql export and import the Chinese table bitsCN.com
Mysql export and import a Chinese table
1. export data for utf8 first:
(1) export all tables of the source database:
Mysqldump-u root-p password -- socket = mysql. sock -- default-character-set = utf8 -- set-charset = utf8 -- hex-blob -- databases Database name> utf8. SQL
(2) modify the SQL file and delete the database creation commands contained in the file header.
(3) log on to the target database
Mysql-uroot-p password -- default-character-set = utf8 -- socket = mysql. sock-
Note: You must specify the character set to log on. In addition, the specified character set must be consistent with the character set specified during export.
(4) delete a database (if any)
Drop database name;
(5) create a database, save it as utf8 storage format, and import
Create database name charset = utf8;
Use database name;
Source utf8. SQL;
After this item is imported, Chinese tables may contain garbled characters. Therefore, use the following method to import a Chinese table.
II. export and import a Chinese table:
# Export
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 ...... > Gbk. SQL
# Import (if the table already exists, it will be deleted before being imported. Therefore, you do not need to delete the existing table in advance)
Mysql-uroot-p password -- default-character-set = gbk -- socket = mysql. sock-A <
Use database name;
Source gbk. SQL
EOF
BitsCN.com