Sample Code for setting all parameters of MySQL character set to UTF8

Source: Internet
Author: User
Today, we will introduce the actual operation steps for setting all the parameters of the MySQL character set to UTF8, this article uses the actual application code that sets all parameters as UTF8 In the MySQL character set to introduce the actual operations. The following is the main content of the text. MySQL character set all parameters are set to UTF8: MySQL (and P

Today, we will introduce the actual operation steps for setting all the parameters of the MySQL character set to UTF8, this article uses the actual application code that sets all parameters as UTF8 In the MySQL character set to introduce the actual operations. The following is the main content of the text. MySQL character set all parameters are set to UTF8: MySQL (and P

Today, we will introduce the actual operation steps for setting all the parameters of the MySQL character set to UTF8, this article uses the actual application code that sets all parameters as UTF8 In the MySQL character set to introduce the actual operations. The following is the main content of the text.

Set all MySQL character set parameters to UTF8: After installation is complete, MySQL (the best combination with PHP) has been set to utf8

But as shown below:

 
 
  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)
  10. MySQL (best combination with PHP)> show variables like 'character _ set _ % ';
  11. + -------------------------- + ------------------------------------------------ +
  12. | Variable_name | Value |
  13. + -------------------------- + ------------------------------------------------ +
  14. | Character_set_client | latin1 |
  15. | Character_set_connection | latin1 |
  16. | Character_set_database | utf8 |
  17. | Character_set_results | latin1 |
  18. | Character_set_server | utf8 |
  19. | Character_set_system | utf8 |
  20. | Character_sets_dir | D: \ data \ MySQL (the best combination with PHP) Server 4.1 \ share \ charsets/|
  21. + -------------------------- + ------------------------------------------------ +
  22. 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 UTF-8 code snippet that sets all parameters for the MySQL character set:

 
 
  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

Start MySQL (the best combination of PHP and MySQL). The following code snippets are available:

 
 
  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 of the MySQL character set to UTF8. I hope you will have some gains.

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.