mysql設置字符集CHARACTER SET
阿新 • • 發佈:2018-10-15
charsets efault result con 編碼 服務 lin spa cli
在 my.cnf 配置文件中設置相關選項,改變為相應的character set。
設置數據庫編碼(sudo vi /etc/mysql/my.cnf):
[client] default-character-set = utf8 [mysqld] character-set-server = utf8 collation-server = utf8_general_ci
查看設置結果
更改my.cnf之前:
mysql> SHOW VARIABLES LIKE ‘%char%‘; +--------------------------+---------------------------------------------------------------+ | Variable_name | Value | +--------------------------+---------------------------------------------------------------+ | character_set_client | utf8 | | character_set_connection | utf8 | | character_set_database | latin1 | | character_set_filesystem | binary | | character_set_results | utf8 | | character_set_server | latin1 | | character_set_system | utf8 | | character_sets_dir | /usr/local/mysql-5.6.21-linux-glibc2.5-x86_64/share/charsets/ | +--------------------------+---------------------------------------------------------------+
設置之後,重啟mysql服務($ sudo service mysql restart):
mysql> SHOW VARIABLES LIKE ‘%char%‘; +--------------------------+---------------------------------------------------------------+ | 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 | /usr/local/mysql-5.6.21-linux-glibc2.5-x86_64/share/charsets/ | +--------------------------+---------------------------------------------------------------+
mysql設置字符集CHARACTER SET