1、SHOW VARIABLES LIKE 'character_set_%';查看编码集
2、编辑/etc/my.cnf文件
加入这个设置
default-character-set=utf8
(这个是一劳永逸的方法)
然后重启mysql服务:
sudo service mysqld restart
再次查看编码集:
就ok了
还有一种是一次性的:
set character_set_client = utf8;
set character_set_server = utf8;
set character_set_connection = utf8;
set character_set_database = utf8;
set character_set_results = utf8;
set collation_connection = utf8_general_ci;
set collation_database = utf8_general_ci;
set collation_server = utf8_general_ci;
这个也行;
还有一种就是修改表的编码方式:
alter table 表名 convert to character set utf8;
这几种方法我感觉第一种最好,因为以后都不用再改了,哈哈哈哈哈哈哈哈