當我們在 MySQL 終端機介面時,查詢資料表結構或資料時,中文字變成 ? 問號

當我們在 MySQL 終端機介面時,查詢資料表結構或資料時,中文字會變成 ? 問號

mysql> describe bowling_stage;
+----------------+-------------------------------------------------+------+-----+---------+----------------+
| Field          | Type                                            | Null | Key | Default | Extra          |
+----------------+-------------------------------------------------+------+-----+---------+----------------+
| stage_id       | smallint(5) unsigned                            | NO   | PRI | NULL    | auto_increment |
| stage_date     | date                                            | NO   |     | NULL    |                |
| stage_location | enum('??????','??????','???????','??????','??') | NO   |     | NULL    |                |
| stage_editor   | varchar(255)                                    | YES  |     | NULL    |                |
| stage_macth    | smallint(5) unsigned                            | NO   |     | NULL    |                |
| stage_time     | enum('??','??','??','??')                       | NO   |     | NULL    |                |
| stage_road     | varchar(255)                                    | YES  |     | NULL    |                |
| stage_note     | text                                            | YES  |     | NULL    |                |
+----------------+-------------------------------------------------+------+-----+---------+----------------+
8 rows in set (0.31 sec)

設定顯示編碼為 utf8

mysql> set names utf8;
Query OK, 0 rows affected (0.00 sec)

再查詢一次,可以正常顯示中文了

mysql> describe bowling_stage;
+----------------+-------------------------------------------------------------------------------------------------------+------+-----+---------+----------------+
| Field          | Type                                                                                                  | Null | Key | Default | Extra          |
+----------------+-------------------------------------------------------------------------------------------------------+------+-----+---------+----------------+
| stage_id       | smallint(5) unsigned                                                                                  | NO   | PRI | NULL    | auto_increment |
| stage_date     | date                                                                                                  | NO   |     | NULL    |                |
| stage_location | enum('黃金保齡球館','一心保齡球館','良美町保齡球館','南方保齡球館','其它') | NO   |     | NULL    |                |
| stage_editor   | varchar(255)                                                                                          | YES  |     | NULL    |                |
| stage_macth    | smallint(5) unsigned                                                                                  | NO   |     | NULL    |                |
| stage_time     | enum('早上','下午','晚上','凌晨')                                                             | NO   |     | NULL    |                |
| stage_road     | varchar(255)                                                                                          | YES  |     | NULL    |                |
| stage_note     | text                                                                                                  | YES  |     | NULL    |                |
+----------------+-------------------------------------------------------------------------------------------------------+------+-----+---------+----------------+
8 rows in set (0.00 sec)

這個方法無法根治,每次重啟 MySQL 服務,都必須再執行一次