以下是检查特定 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)