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

Source: Internet
Author: User
Tags mysql command line

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:

1 altertable tb_anniversary convert to character setutf8;

Modify the database MySQL character encoding to UTF8:

Windows MySQL default character set modification

first, modify through the MySQL command line:


Set Character_set_client=utf8;

Set Character_set_connection=utf8;

Set Character_set_database=utf8;

Set Character_set_results=utf8;

Set Character_set_server=utf8;


Support for character sets is refined to four levels:
Servers (server), database, data tables (table), and connections (connection).

The settings for viewing the character set and ordering of the system can be set through the following two commands:

SHOW VARIABLES like ' character% ';

SHOW VARIABLES like ' collation_% ';

Second, modify the encoding method by MySQL file

1. Locate the My.ini file in the MySQL installation directory (if not, copy the My-medium.ini, then rename it to My.ini)

2. Find the [client] and [mysqld] fields in the My.ini file, add Default-character-set=utf8 below, save and close

    • [MySQL]
    • Default-character-set=utf8
    • [Mysqld]
    • Character-set-server=utf8

3. Restart MySQL Service

"The default encoding Default-character-set=utf8 can also be changed to DEFAULT-CHARACTER-SET=GBK"

, 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.