问题是由mysql的编码问题造成
1.首先考虑是否是mysql编码的问题
查看mysql的字符集:show variables where Variable_name like '%char%';
修改mysql的字符集:
mysql> set character_set_client=utf8;
mysql> set character_set_connection=utf8;
mysql> set character_set_database=utf8;
mysql> set character_set_results=utf8;
mysql> set character_set_server=utf8;
mysql> set character_set_system=utf8;
mysql> set collation_connection=utf8;
mysql> set collation_database=utf8;
mysql> set collation_server=utf8;
2.是否是数据库编码的问题
查看数据库的字符集:show create database enterprises;
修改数据库的字符集:alter database enterprises character set utf8
3.是否是表的编码问题
查看表的字符集:show create table employees;(位于建表语句的末尾)
修改表的字符集:alter table employees character set utf8
修改字段的字符集:alter table employees change name name char(10) character set utf-8; |