mysql>show variables like 'character%'; //查看当前
数据库的字符编码
+--------------------------+----------------------------+
| Variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | latin1 |
| character_set_connection | latin1 |
| character_set_database | latin1 |
| character_set_filesystem | binary |
| character_set_results | latin1 |
| character_set_server | latin1 |
| character_set_system | latin1 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
default-character-set=utf8 //默认字符集为utf8
init_connect='SET NAMES utf8' //(设定连接
mysql数据库时使用utf8编码,以让mysql数据库为utf8运行)