Mysql modifies the database encoding (database character set) and Table character encoding methods, mysql Character Set

Source: Internet
Author: User

Mysql modifies the database encoding (database character set) and Table character encoding methods, mysql Character Set

Mysql database is an open-source database and is widely used. The following describes how to modify the character encoding of the mysql database and convert the character encoding of the table to UTF-8. For more information, see.

Mysql converts the character encoding of a table to UTF-8:

alter table tb_anniversary convert to character set utf8;

Modify 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, you insert a character type (char) record to the data table. When this record is displayed, data of the character type may not be displayed normally, therefore, we can change the mysql character encoding to UTF8. The procedure is as follows:

Step 2: Modify the my. cnf configuration file as follows (/etc/my. cnf ):

[Client] # password = your_passwordport = 3306 socket =/var/lib/mysql. sockdefault-character-set = utf8 # set the default encoding to UTF8

To query the details of each field in the current table: show full columns from table_name;

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.