mysql> create database if not exists local default character set = 'utf8'; Query OK, 1 row affected (0.00 sec)
备注:通过default character set = 语句来指定DB的字符集
mysql> select schema_name,default_character_set_name from information_schema.schemata where schema_name = 'local'; +-------------+----------------------------+ | schema_name | default_character_set_name | +-------------+----------------------------+ | local | utf8 | +-------------+----------------------------+ 1 row in set (0.00 sec)
备注:通过系统表schemata查看可以知道,DB的字符集是utf8的.同时,数据库的字符集是utf8,那么在这个数据库下创建的表的字符集也都是utf8的.也就是数据库的字符集对于后续创建的表是有影响的.