MySQL modifies character encoding

Source: Internet
Author: User
MySQL modifies character encoding

19:30:52 | category: Technical Exchange | font size subscription

1. Open c: \ Program Files \ mysql \ MySQL Server 5.0 \ My. ini


Search for default-character-set under [client] and change its value:
Default-character-set = utf8

If the default-character-set cannot be found, add the above line.


[Mysqld] Likewise:
Default-character-set = utf8

Init_connect = 'set names utf8'



The following statement is used to check whether the encoding method has been modified:

Show variables like 'Char % ';


2. Appendix: For an existing database, you can perform the following operations to change the encoding method:

A. Modify the MySQL database encoding. If the MySQL database encoding is incorrect, run the following command in MySQL: Alter database test default Character Set utf8; 

The preceding command sets the encoding of MySQL's test database to utf8.

B. Modify the MySQL table encoding: ALTER TABLE category default Character Set utf8;

The preceding command changes the category encoding of a table to utf8.

C. Modify the field encoding:

Alter table 'test' change 'dd' dd' varchar (45) Character Set utf8 collate utf8_bin not null

The preceding command changes the DD field encoding in the MySQL database test table to utf8.


The following code inserts a Chinese character in a command line:
Set names gb2312;

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.