mysql> show create table test;
| blog_ml | CREATE TABLE `blog_ml` (
`id` bigint(20) NOT NULL,
`blogid` bigint(20) NOT NULL,
`ml_code` varchar(10) CHARACTER SET latin1 NOT NULL,
`title` varchar(150) CHARACTER SET latin1 DEFAULT NULL,
`description` text CHARACTER SET latin1,
`tags` varchar(150) CHARACTER SET latin1 DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `blog_blogid_index` (`blogid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8
可以看到
ENGINE=InnoDB DEFAULT CHARSET=utf8,
表的字符编码是utf8
但是`title` varchar(150) CHARACTER SET latin1 DEFAULT NULL,
字段编码是latin1
修改:
ALTER TABLE `blog_ml` MODIFY COLUMN `ml_code` varchar(10) NOT NULL;
ALTER TABLE `blog_ml` MODIFY COLUMN `title` varchar(150) DEFAULT NULL;
ALTER TABLE `blog_ml` MODIFY COLUMN `description` text;
ALTER TABLE `blog_ml` MODIFY COLUMN `tags` varchar(150) DEFAULT NULL;