Modify the encoding format MySQL

Source: Internet
Author: User

The way to modify the character set is to use the MySQL command mysql> SET character_set_client = UTF8; mysql> SET character_set_connection = UTF8; use mysql> show VARIABLES like ' character% '; view, discover that database encoding has been changed to UTF8

  +--------------------------+---------------------------------+  | variable_name | & #118alue |

   +--------------------------+---------------------------------+ | character_set_client | UTF8 || character_set_connection | UTF8 || character_set_database | UTF8 || character_set_filesystem | binary || character_set_results | UTF8 || character_set_server | UTF8 || character_set_system | UTF8 || character_sets_dir | D: "mysql-5.0.37" Share "charsets" | +

  --------------------------+---------------------------------+

  mysql> SHOW VARIABLES like ' collation_% ';

  +----------------------+-----------------+

  | variable_name | & #118alue |

  +----------------------+-----------------+

  | collation_connection | Utf8_general_ci |

  | Collation_database | Utf8_general_ci |

  | Collation_server | Utf8_general_ci |

  +----------------------+-----------------

  or open the MySQL installation directory, there is a My.ini file, open this file, there are two character set settings, the default is Latin, it is recommended that you want to change, such as: UTF8 or GBK and then start the MySQL service, the default character set of the database created later is OK (restart, Open the Mysqladministrator service control to do it. )

  Some other ways to modify MySQL encoding:

  1. If the installation of MySQL code can not be changed, many friends are buying a virtual host to build a website, do not have the right to change the installation code of MySQL, this level we can skip, because as long as the following step together correctly, as can solve the garbled problem

  2. Modify the database encoding, if the database encoding is incorrect: You can execute the following command in phpMyAdmin: ALTER database ' test ' DEFAULT CHARACTER SET UTF8 COLLATE utf8_bin the above command is to set the test database encoding to UTF8

  3. Modify the table's encoding: ALTER table ' category ' DEFAULT CHARACTER SET UTF8 COLLATE utf8_bin The above command is to change the encoding of a table category to UTF8

  4. Modify the encoding of the field: ALTER TABLE ' test ' change ' dd ' "dd ' VARCHAR" CHARACTER SET UTF8 COLLATE utf8_bin not NULL The above command is to change the field encoding of DD in the test table to UTF8


Technology sharing: Edith Academy

This article from the "11247808" blog, reproduced please contact the author!

Modify the encoding format MySQL

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.