1、更改服務器的編碼方式,在終端輸入以下命令:mysqld--character-set-server=gbk--collation-server=gbk_chinese_ci;
2、更改某個數據庫的編碼方式mysql-uroot-p alterdatabasecharactersetgbkcollategbk_chinese_ci;
3、在創建數據庫時指定編碼:mysql-uroot-p createdatabasedb_namecharactersetgbkcollategbk_chinese_ci;
4、更改某個表的編碼方式mysql-uroot-pdb_namealtertabletable_nameconvertto charachtersetgbkcollategbk_chinese_ci;
5、在創建表時指定編碼方式mysql-uroot-pdb_namecreatetabletable_name(....)charactersetgbkcollategbk_chinese_ci;
6、更改某行的編碼方式mysql-uroot-pdb_namealtertabletable_namemodifycolumn_namevarchar(20)charactersetgbkcollategbk_chinese_ci;
7、在創建列時指定編碼方式:</pre><prename="code"class="sql">mysql-uroot-pdb_namecreatetabletable_name(...,col1varchar(20)charactersetgbkcollategbk_chinese_ci,...)charactersetutf8collateutf8_general_ci;