For cases where the database is garbled, first look at the database encoding
1. View Database encoding
2, set the connection code
The encoding of the server, database, and data table sections is set, and the connection encoding must be set. The connection encoding settings are as follows: mysql> set character_set_client= ' UTF8 ';
mysql> SET character_set_connection= ' UTF8 '
mysql> SET character_set_results= ' UTF8 '
Set the connection code, the following can be successfully inserted in Chinese: mysql> insert INTO mysqlcode values (null, ' Java enthusiasts ');
Query OK, 0 rows affected (0.02 sec)
In fact, the above three commands to set the connection code can be simplified to one: mysql> set names ' UTF8 '; Note: The above UTF8 is based on your database encoding settings, if the database is GBK, then modify to GBK can! 3, complete the execution of the SQL statement, note that this is performed here on the "mysql>" command line if you want to execute it at the command line [[email protected] mqc]#: [[email protected] mqc]# Mysql-uroot- P --default-character-set=utf8 dbname < Dbname.sql
For MySQL import garbled settings