5 ways to insert Chinese without garbled MySQL

Source: Internet
Author: User


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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.