Current location - Training Enrollment Network - Books and materials - How to set the default character set encoding of Mysql database to GBK
How to set the default character set encoding of Mysql database to GBK
1. Change the encoding mode of the server and enter the following command at the terminal:

mysqld-character-set-server = gbk-collation-server = gbk _ Chinese _ ci;

2. Change the coding method of the database.

mysql -u root -p?

Change the database character set;

3. Specify the code when creating the database:

mysql -u root -p?

Create database db_name character set gbk proofreading gbk _ chinese _ ci

4. Change the coding method of the table.

mysql -u root -p db_name

Convert table_name to? Character set proofreading; ?

5. Specify the encoding method when creating the table.

mysql -u root -p db_name

Create table_name (...) character set gbk collate gbk _ chinese _ ci.

6. Change the coding method of lines

mysql -u root -p db_name

Alter Table Table _ Name Modify Column _ Name Varchar (20) Character Set gbk collate gbk _ chinese _ ci

7. Specify the encoding method when creating a column:

& lt/pre & gt; & ltpre name="code" class="sql " >mysql -u root -p db_name

Create table_name (..., col 1 varchar(20) character set gbk collate gbk_chinese_ci, ...) character set utf8 collate utf8 _ general _ ci.