1. 編輯/etc/my.cnf文件, 在"[client]"下添加"default-character-set=utf8"
2. 編輯/etc/my.cnf文件, 在"[mysqld]"下添加"default-character-set=utf8"
3. 重新啟動(dòng)mysql服務(wù)
# sudo /etc/init.d/mysqld restart
* 查看系統(tǒng)字符集和排序方式-
mysql> SHOW VARIABLES LIKE 'collation\_%';
+--------------------------+--------+
| 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 |
+--------------------------+--------+
mysql> SHOW VARIABLES LIKE 'character\_set\_%';
+----------------------+-----------------+
| Variable_name | Value |
+----------------------+-----------------+
| collation_connection | utf8_general_ci |
| collation_database | utf8_bin |
| collation_server | utf8_general_ci |
+----------------------+-----------------+
4. 設(shè)置數(shù)據(jù)庫字符集
mysql> create database <database> default character set utf8 default collate utf8_bin;
或者修改已有數(shù)據(jù)庫
mysql> alter database <database> default character set utf8 default collate utf8_bin;
* 查看mysql支持的所有的COLLATION
mysql> SHOW COLLATION;
本文出自:億恩科技【mszdt.com】
服務(wù)器租用/服務(wù)器托管中國五強(qiáng)!虛擬主機(jī)域名注冊頂級(jí)提供商!15年品質(zhì)保障!--億恩科技[ENKJ.COM]
|