本文測試環境爲Windows Server 2008 R2系統,MySQL版本爲MariaDB 10.1.32。mysql
首先查看服務器字符集設置。sql
C:\Users\Administrator>mysql Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 32 Server version: 10.1.32-MariaDB mariadb.org binary distribution Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]> show variables like 'character%'; +--------------------------+--------------------------------+ | Variable_name | Value | +--------------------------+--------------------------------+ | character_set_client | gbk | | character_set_connection | gbk | | character_set_database | latin1 | | character_set_filesystem | binary | | character_set_results | gbk | | character_set_server | latin1 | | character_set_system | utf8 | | character_sets_dir | C:\xampp\mysql\share\charsets\ | +--------------------------+--------------------------------+ 8 rows in set (0.00 sec)
修改服務器默認字符集設置。其餘設置也能夠修改Variable_name和Value設置。數據庫
MariaDB [(none)]> set character_set_server=utf8; Query OK, 0 rows affected (0.00 sec)
本文設置完成後查詢結果以下。服務器
MariaDB [(none)]> show variables like 'character%'; +--------------------------+--------------------------------+ | Variable_name | Value | +--------------------------+--------------------------------+ | character_set_client | utf8 | | character_set_connection | utf8 | | character_set_database | utf8 | | character_set_filesystem | binary | | character_set_results | utf8 | | character_set_server | utf8 | | character_set_system | utf8 | | character_sets_dir | C:\xampp\mysql\share\charsets\ | +--------------------------+--------------------------------+ 8 rows in set (0.00 sec) MariaDB [(none)]>
注意:不一樣客戶端鏈接數據庫查詢結果不必定徹底相同。測試