Recently, I got a MySQL script file of dozens of MB, which is ready to be restored to a 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 haveDefault 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 following command:Use B;
4) Changing the File Reading character set to utf8 is critical.
At the beginning, you can seeDefault 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 following command:Set names utf8;Note that it is not set names UTF-8;
5) Import files
Enter the following 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!