Description of character set parameters in MySQL database

Source: Internet
Author: User

The following article describes how to set all the parameters of the character set in the MySQL database to UTF8. We all know that after the installation is complete, the MySQL database is set to utf8, however, the following content may sometimes appear:

 
 
  1. MySQL (best combination with PHP)> show variables like 'collation _ % ';
  2. + ---------------------- + ------------------- +
  3. | Variable_name | Value |
  4. + ---------------------- + ------------------- +
  5. | Collation_connection | latin1_swedish_ci |
  6. | Collation_database | utf8_general_ci |
  7. | Collation_server | utf8_general_ci |
  8. + ---------------------- + ------------------- +
  9. 3 rows in set (0.00 sec)

MySQL (best combination with PHP)> show variables like 'character _ set _ % ';

 
 
  1. + -------------------------- + ------------------------------------------------ +
  2. | Variable_name | Value |
  3. + -------------------------- + ------------------------------------------------ +
  4. | Character_set_client | latin1 |
  5. | Character_set_connection | latin1 |
  6. | Character_set_database | utf8 |
  7. | Character_set_results | latin1 |
  8. | Character_set_server | utf8 |
  9. | Character_set_system | utf8 |
  10. | Character_sets_dir | D: \ data \ MySQL (the best combination with PHP) Server 4.1 \ share \ charsets/|
  11. + -------------------------- + ------------------------------------------------ +
  12. 7 rows in set (0.00 sec)

It is found that the property of the line mark is not utf8.

Modify the my. ini file and set

The following is a code snippet:

 
 
  1. [Client]
  2. Default-character-set = utf8
  3. [MySQL (best combination with PHP)]
  4. Default-character-set = utf8
  5. [MySQL (the best combination with PHP) d]
  6. Default-character-set = utf8

Copy my. ini file to the windows directory

The following code snippet is used to start the MySQL database:

 
 
  1. MySQL (best combination with PHP)> show variables like 'character _ set _ % ';
  2. + -------------------------- + ------------------------------------------------ +
  3. | Variable_name | Value |
  4. + -------------------------- + ------------------------------------------------ +
  5. | Character_set_client | utf8 |
  6. | Character_set_connection | utf8 |
  7. | Character_set_database | utf8 |
  8. | Character_set_results | utf8 |
  9. | Character_set_server | utf8 |
  10. | Character_set_system | utf8 |
  11. | Character_sets_dir | D: \ data \ MySQL (the best combination with PHP) Server 4.1 \ share \ charsets/|
  12. + -------------------------- + ------------------------------------------------ +
  13. 7 rows in set (0.00 sec)
  14. MySQL (best combination with PHP)> show variables like 'character _ set _ % ';
  15. + -------------------------- + ------------------------------------------------ +
  16. | Variable_name | Value |
  17. + -------------------------- + ------------------------------------------------ +
  18. | Character_set_client | utf8 |
  19. | Character_set_connection | utf8 |
  20. | Character_set_database | utf8 |
  21. | Character_set_results | utf8 |
  22. | Character_set_server | utf8 |
  23. | Character_set_system | utf8 |
  24. | Character_sets_dir | D: \ data \ MySQL (the best combination with PHP) Server 4.1 \ share \ charsets/|
  25. + -------------------------- + ------------------------------------------------ +
  26. 7 rows in set (0.00 sec)

Everything is normal.

Create a database:

The following is a code snippet:

 
 
  1. Create table t_sysuser (
  2. USERID integer not null auto_increment,
  3. USERNAME varchar (30 ),
  4. PASSWORDS varchar (30 ),
  5. DEPTNO varchar (30 ),
  6. HEADSHIP varchar (30 ),
  7. SEX varchar (4 ),
  8. TEL varchar (18 ),
  9. EMAIL varchar (30 ),
  10. URL varchar (30 ),
  11. PCALL varchar (20 ),
  12. USERPHOTO varchar (255 ),
  13. FACEREFUTIME integer,
  14. FACELANGUAGE varchar (1 ),
  15. LASTMODIF varchar (30 ),
  16. LASTMDATE datetime,
  17. CREADTOR varchar (30 ),
  18. CREATDATE datetime,
  19. Prima (the most comprehensive virtual host Management System) ry key (USERID)
  20. ) ENGINE = InnoDB default charset = utf8;

All done.

The above content is an introduction to setting all the parameters UTF8 for the character set of the MySQL database.

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.