MySql: charset and collation settings

Source: Internet
Author: User

MySql: charset and collation settings charset and collation have multiple levels of settings: Server-level, database-level, table-level, column-level, and connection-level www.2cto.com 1. server-level viewing settings: show global variables like 'character _ set_server '; and show global variables like 'collation _ Server'; modify the settings: In option file (/etc/mysql/my. cnf): [mysqld] character_set_server = utf8 collation_server = utf8_general_ci 2. database-level viewing settings: select * from information_schema.schemata where schema_name = 'cookbook'; settings: 1. if no explicit settings are available, server-level configuration is automatically used. explicit settings: when creating a database, specify create database playUtf8 default character set latin1 COLLATE latin1_swedish_ci; www.2cto.com 3. table-level viewing settings: show create table course; settings: 1. if no explicit settings are available, the database-level configuration is automatically used. explicit setting: when creating a table, specify create table utf (id int) default charset = utf8 default collate = utf8_bin; 4. column-level viewing settings: show create table course; settings: 1. if no explicit settings are available, table-level configuration is automatically used. explicit settings: create table Table1 (column1 VARCHAR (5) CHARAC Ter set latin1 COLLATE latin1_german1_ci); 5. view the connection level settings: show variables like 'character _ set_client '; # The server uses this encoding to understand the statements show variables like 'character _ set_connection' sent from the client '; # I still don't know what it means. After reading the mysql source code, let's talk about show variables like 'character _ set_results '; # The server uses this encoding to return the result set and set the error message: the client can specify these parameters during connection. At the same time, the server also provides a Global value. If the client does not specify these parameters, the server uses this Global value. How do I set this global value? I have checked many documents and it seems that I haven't seen the setting method (someone said that my. cnf, or the command line parameter specified when mysqld is started, is actually an error.) Appendix: What encoding does connector/j use to transmit SQL statements? Answer: "The character encoding between client and server is automatically detected upon connection. the encoding used by the driver is specified on the server using the character_set_server system variable for server versions 4.1.0 and newer. "That is to say, it is to query the character_set_server value of the server during connection, and then determine the encoding used by the connection. However, the official document also says, "to override the automatic detection encoding function on the client, you can use the" characterEncoding "attribute in the URL used to connect to the server."

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.