好吧最近年纪大了记不住东西,上次建数据库把编码格式写错了导致浪费时间去调试
写这里好了~
//默认字符集utf8:
CREATE DATABASE IF NOT EXISTS yourdbname DEFAULT CHARSET utf8 COLLATE utf8_general_ci;
//默认gbk字符集:
create database yourdb DEFAULT CHARACTER SET gbk COLLATE gbk_chinese_ci;
另外查看table所用的字符集:
show create table tb_name;
转自 http://outofmemory.cn/code-snippet/2533/mysql-create-database-specify-utf-8-coding