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;