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

Source: Internet
Author: User

The MySQL database is an open-source database that is widely used. The following is a procedure for modifying the character encoding of a MySQL database and converting the character encoding of a table into a Utf-8 method, which a friend can refer to.

MySQL converts the character encoding of a table into Utf-8:

ALTER TABLE Tb_anniversary convert to character set UTF8;

Modify the database MySQL character encoding to UTF8:

Step 1: View the current character encoding method:

    

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 character type (char) record into the data table, which may not display the character type's data properly when displaying this record, so we modify the MySQL character encoding to UTF8. The operation is as follows:

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

[client] #password      = your_passwordport           = 3306socket         =/var/lib/mysql/mysql.sockdefault-character-set= UTF8     #设置默认编码为UTF8

, query the details of each field in the current table: Show full columns from table_name;

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

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.