以下是查询以检查特定MySQL数据库的默认字符集的查询-
mysql> SELECT SCHEMA_NAME 'DatabaseName', default_character_set_name 'Charset' FROM information_schema.SCHEMATA where schema_name = 'db_name';
例如,以下查询将返回名为“ Sample”的数据库的默认字符集-
mysql> SELECT SCHEMA_NAME 'DatabaseName', default_character_set_name 'Charset' FROM information_schema.SCHEMATA where schema_name = 'Sample'; +----------------+---------+ | DatabaseName | Charset | +----------------+---------+ | Sample | latin1 | +----------------+---------+ 1 row in set (0.00 sec)