Use the mysql command line to restore the phpMyAdmin exported SQL file containing Chinese characters.
BitsCN.com recently obtained a MySQL script file of dozens of MB, ready to be restored to the database.
I used MySQL-Front for a short time. I tried it first and the result was suspended.
In this case, create an empty database with MySQL-Front and use the mysql command line to import the database.
1) an empty database is created using MySQL-Front.
Because all objects in the script have default charset = gbk COMMENT =... Command, so select gbk for the character set
2) start MySQL command line and enter the password
3) use the new database B
Enter the command: use B;
4) changing the file reading character set to utf8 is critical.
Start with default charset = gbk COMMENT =... To set it to gbk, the following command is used:
Set names gbk;
However, during import, all errors are caused and Chinese characters cannot be recognized.
Later I realized that it should be set to the character set of the SQL file itself. what is the character set of the SQL file itself?
My method is to open the file with VS.net IDE, save it as, and select "save encoding"
The character set is UTF-8;
So
Enter the command: set names utf8; note that it is not set names UTF-8;
5) import files
Enter the command: source file path;
Soon, the file is successfully imported into the database, which is highly efficient.
Go to MySQL-Front and check that the data is imported normally!
BitsCN.com