MySQL inserted in Chinese does not garbled 5 ways:
Method One:
Log in to MySQL, set names Latin1 first, and then update the statement or execute the SQL statement
Mysql> set names latin1;mysql> source Test.sql;
Method Two:
Specify set names latin1 in the SQL file, and then log in to MySQL to execute the corresponding file
[email protected] ~]# cat Test.sql Set names Latin1;insert *****************;mysql> source Test.sql;
Method Three:
Specify set names latin1 in the SQL file, and then import through the MySQL command
[Email protected] ~]# mysql-uroot-p123456 test <test.sql
Method Four:
Implement--default-character-set=latin1 by specifying the character set parameters of the MySQL command
[email protected] ~]# cat test.sql Insert *****************; [Email protected] ~]# mysql-uroot-p123456--default-character-set=latin1 test <test.sql
Method Five: recommend this method, but it is recommended to use UTF8
Setting client and server-side related parameters in the configuration file
That is, modify the module parameters of the MY.CNF client, can implement the set names UTF8, and the permanent effect
[Client] Default-character-set=utf8 no need to restart MySQL, exit the current login, login again [Server] Default-character-set=utf8 5.1 previous version Chara Cter-set-server=utf8 version 5.5
Library tables, Programs!
CREATE DATABASE wyb DEFAULT CHARACTER SET UTF8 collate utf8_general_cli;
Summary table of Character set meanings
mysql> show variables like ' character_set% '; | character_set_client | utf8 #客户端字符集 | character_set_connection | utf8 #链接字符集 | character_set_database | utf8 # Database character set, configuration file specified or specified at creation time | character_set_results | utf8 #返回结果字符集 | character_set_server | utf8 #服务器字符集, config file, or create a library, when the table specifies
This article is from the "Crazy_sir" blog, make sure to keep this source http://douya.blog.51cto.com/6173221/1787793
5 ways to insert Chinese without garbled MySQL