1. 程式人生 > >Linux Mysql5.6.42修改字符集

Linux Mysql5.6.42修改字符集

  1. 進入/etc目錄下
cd /etc
  1. 開啟my.cnf檔案
vim my.cnf
  1. 修改以下部分(Mysql5.6.42預設的配置檔案中可能沒有[client和[mysql],直接新增即可)
[client]
port = 3306
socket = /var/lib/mysql/mysql.sock
default-character-set=utf8

[mysqld]
character_set_server = utf8
character_set_client = utf8
collation-server = utf8_general_ci

[
mysql] no-auto-rehash default-character-set=utf8 # 將這段話註釋掉,否則將會報錯 # sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
  1. 檢視字符集
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/share/mysql/charsets/ | +--------------------------+----------------------------+ 8 rows in set (0.00 sec)