1.使用create database語句創建數據庫
mysql> create database if not exists test03 default character set = 'utf8';
Query OK, 1 row affected (0.00 sec)
備注:通過default character set = 語句來指定DB的字符集.
2.查看創建的DB的字符集
mysql> select schema_name,default_character_set_name from information_schema.schemata where schema_name = 'test03'; +-------------+----------------------------+ | schema_name | default_character_set_name | +-------------+----------------------------+ | test03 | utf8 | +-------------+----------------------------+ 1 row in set (0.00 sec)
備注:通過系統表schemata查看可以知道,DB的字符集是utf8的.同時,數據庫的字符集是utf8,那么在這個數據庫下創建的表的字符集也都是utf8的.也就是數據庫的字符集對於后續創建的表是有影響的.