mysql???????????????Latin1???????????????????gbk/utf8?????????
1????root????????????????????
???????>mysql -u root –p ?????????????????????????????
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/ |
+--------------------------+----------------------------+
??????????????????? ??????????????????????gbk??utf8.
character_set_client????????????
character_set_connection????????????????
character_set_database?????????
character_set_results??????????
character_set_server???????????????
?????????????????????????????????????????
2????????????????裺
1????mysql????
2?????mysql?????????
windows?????·???μ??my.ini
linux??·????????/etc/mysql/my.cnf
3)????????????[client] ?????????
default-character-set=utf8 ?????????utf8
4???????[mysqld] ???
default-character-set=utf8 ?????????utf8
init_connect='SET NAMES utf8' ???趨????mysql?????????utf8????????mysql??????utf8???У?
5?????ú????????mysql????????????????
>show variables like 'character%';
+--------------------------+----------------------------+
| Variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | utf8 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | utf8 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
3??MySQL???????????????????????????????????????????м???????????????????μ???????
?????????????????????????????????????
1??CREATE  DATABASE  ms_db  CHARACTER SET  utf8  COLLATE utf8_general_ci??
2??create  database  if  not  exists  netctoss  default character set utf8;
3??????????????????????????????????????????????????磺jdbc:mysql://localhost:3306 /mysql?useUnicode=true&characterEncoding=utf-8(???????????κο?????????)
4????Commandline????????????????????????????
set names gbk(???????UTF-8) ???????????????????????????????
???set names gbk????????character_set_client??character_set_connection?? character_set_results?????????????????????????????????????????Ч?????′????????Ч??????????????????????????????????utf8??????洢??