Modifying the MySQL character set

Source: Internet
Author: User

First Kind

First, modify the My.ini configuration file (MySQL configuration file)

Character_set_server = UTF8 #设置字符集

Restart MySQL database service

View the current database character set

' character% ';

Second, modify the database character set

set UTF8;

PS: After modifying the database character set, the MySQL database needs to be restarted.

Third, modify the table character set

ALTER table  name DEFAULT CHARACTER SET UTF8 COLLATE utf8_general_ci

Iv. modifying the column character set

ALTER table  name change  column Name column name   CHARACTER set UTF8 COLLATE utf8_general_ci null DEFAULT null;

The second Kind

Modifying the encoding format of a table

Modify the encoding format of a field because the table's encoding changes the field's not so also to modify the field modification field can only change

ALTER TABLE ' tablename ' Change ' field name 1 ' Field Name 2 ' VARCHAR (

The ultimate way to modify multiple lines

Set

Third Kind

1: View the current character encoding method
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/|+--------------------------+----------------------------+8Rowsinch Set(0.00Sec
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. Actions are as follows: Step 2: Modify the MY.CNF configuration file, as follows (/ETC/MY.CNF):
[client] #password       = your_passwordport           3306socket         =/var/lib/mysql/Mysql.sock default-character-set=utf8     #设置默认编码为UTF8

Modifying the MySQL character set

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.