Mysql modifies the database encoding (database character set) and the method of the character encoding of the table _mysql

Source: Internet
Author: User

MySQL converts the character encoding of a table to Utf-8

Copy Code code as follows:

ALTER TABLE Tb_anniversary convert to character set UTF8;

Modify database MySQL character encoding for UTF8

Step 1: View the current character encoding method

Copy Code code as follows:

Mysql> Show variables like ' character% ';

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

| variable_name | Value |

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

|character_set_client |latin1 |

| Character_set_connection |latin1 |

| Character_set_database |latin1 |

| Character_set_filesystem |binary |

|character_set_results |latin1 |

|character_set_server |latin1 |

|character_set_system |utf8 |

|character_sets_dir | /usr/share/mysql/charsets/|

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

8 rows in Set (0.00 sec)

When the character encoding is latin1, the user inserts a record of character type (char) into the datasheet, and the character type data may not display correctly when this record is displayed, so we modify the MySQL character encoding to UTF8. The operation is as follows:

Step 2: Modify the MY.CNF configuration file as follows (/ETC/MY.CNF):

Copy Code code as follows:

[Client]

#password = Your_password

Port = 3306

Socket =/var/lib/mysql/mysql.sock

Default-character-set=utf8 #设置默认编码为UTF8

Related Article

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.