标签:
二:mysql乱码原因:
1 mysql>show variables like ‘character%‘; 2 +--------------------------+----------------------------+ 3 | Variable_name | Value | 4 +--------------------------+----------------------------+ 5 | character_set_client | latin1 | 6 | character_set_connection | latin1 | 7 | character_set_database | latin1 | 8 | character_set_filesystem | binary | 9 | character_set_results | latin1 | 10 | character_set_server | latin1 | 11 | character_set_system | utf8 | 12 | character_sets_dir | /usr/share/mysql/charsets/ | 13 +--------------------------+----------------------------+、 15 mysql> show variables like ‘collation%‘;(或者使用 >show variables like ‘collation%‘;) 16 +----------------------+-------------------+ 17 | Variable_name | Value | 18 +----------------------+-----------------------+ 19 | collation_connection | latin1_swedish_ci | 20 | collation_database | latin1_swedish_ci | 21 | collation_server | latin1_swedish_ci | 22 +----------------------+-----------------------+
1 CREATE DATABASE `datatest` 2 CHARACTER SET ‘utf8‘ 3 COLLATE ‘utf8_general_ci‘;
1 CREATE TABLE `database_user` ( 2 `id` varchar(40) NOT NULL default ‘‘, 3 `name` varchar(40) NOT NULL default ‘‘, 4 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1 ALTER DATABASE `test` DEFAULT CHARACTER SET utf8 COLLATE utf8_bin;
1 ALTER TABLE `test` DEFAULT CHARACTER SET utf8 COLLATE utf8_bin;
1 ALTER TABLE `test` CHANGE `name` `name` VARCHAR( 10 ) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL;
标签:
原文地址:http://www.cnblogs.com/zyf-zhaoyafei/p/4396265.html