Mysql encoding _ MySQL

Source: Internet
Author: User
Mysql encoding is added to my. ini, and sometimes not used.
[Mysqld]
Default-storage-engine = MyISAM
Default-character-set = utf8
Default-collation = utf8_general_ci




View character encoding
Show variables like 'character % ';
Single Character encoding
SET character_set_client = utf8;
SET character_set_connection = utf8;
SET character_set_database = utf8;
SET character_set_results = utf8;
SET character_set_server = utf8;

SET collation_connection = utf8;
SET collation_database = utf8;
SET collation_server = utf8;


① We want to tell the server what encoding the data I sent you is
Character_set_client
② Tell the character set converter what encoding to convert
SET character_set_connection
③ Encoding of the query result
Character_set_results
If the preceding three parameters are utf8, you can abbreviated them as set names 'utf8 ';






Specify encoding rules when creating databases and tables using SQL statements
Create database if not exists test default character set gbk COLLATE gbk_bin;
Create table 'tbz '(
'Yz' varchar (3) not null,
'Bzmc 'varchar (16) not null,
'Bzbm 'varchar (1) default null,
'SM 'varchar (20) default null,
Primary key ('BZ ')
) ENGINE = InnoDB default charset = gbk COLLATE gbk_bin;




Show current default rules
Show collation like 'gbk % ';

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.