Mysql Character Set viewing settings

Source: Internet
Author: User
(1) The simplest modification method is to modify mysql's my. INI file character set key value, such as default-character-setutf8character_set_serverutf8 after modification, restart mysql service, servicemysqlrestart using mysqlSHOWVARIABLESLIKEcharacter %; view, found that the database encoding are

(1) The simplest modification method is to modify mysql's my. the character set key value in the INI file, such as default-character-set = utf8 character_set_server = after utf8 is modified, restart the mysql service. service mysql restart uses mysql show variables like 'character % '; check and find all database Codes


(1) The simplest modification method is to modify the character set key value in mysql's my. ini file,

For example, default-character-set = utf8
Character_set_server = utf8

After modification, restart the mysql service, service mysql restart

Use mysql> show variables like 'character % '; Check that the database encoding has been changed to utf8

 
 
  1. +--------------------------+---------------------------------+
  2. | Variable_name | Value |
  3. +--------------------------+---------------------------------+
  4. | character_set_client | utf8 |
  5. | character_set_connection | utf8 |
  6. | character_set_database | utf8 |
  7. | character_set_filesystem | binary |
  8. | character_set_results | utf8 |
  9. | character_set_server | utf8 |
  10. | character_set_system | utf8 |
  11. | character_sets_dir | D:"mysql-5.0.37"share"charsets" |
  12. +--------------------------+---------------------------------+

(2) another way to modify the default Character Set of mysql is to use the mysql command.

 
 
  1. mysql> SET character_set_client = utf8 ;
  2. mysql> SET character_set_connection = utf8 ;
  3. mysql> SET character_set_database = utf8 ;
  4. mysql> SET character_set_results = utf8 ;
  5. mysql> SET character_set_server = utf8 ;
  6. mysql> SET collation_connection = utf8 ;
  7. mysql> SET collation_database = utf8 ;
  8. mysql> SET collation_server = utf8 ;

Generally, even if you set the default mysql Character Set of the table to utf8 and send the query by UTF-8 encoding, you will find that the database is still garbled. The problem lies in the connection layer. The solution is to execute the following statement before sending the query:

 
 
  1. SET NAMES 'utf8';

It is equivalent to the following three commands:

 
 
  1. SET character_set_client = utf8;
  2. SET character_set_results = utf8;
  3. SET character_set_connection = utf8;

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.