mysql数据库无法插入中文字符,查看发现character_set_database和character_set_server不是utf8,将其设置为utf8:
set character_set_database=utf8;
set character_set_server=utf8;
问题解决
mysql> show variables like ‘char%’;
±-------------------------±--------------------------------------------+
| Variable_name | Value |
±-------------------------±--------------------------------------------+
| character_set_client | gbk |
| character_set_connection | gbk |
| character_set_database | latin1 |
| character_set_filesystem | binary |
| character_set_results | gbk |
| character_set_server | latin1 |
| character_set_system | utf8 |
| character_sets_dir | E:\environment\mysql-5.7.19\share\charsets\ |
±-------------------------±--------------------------------------------+
8 rows in set, 1 warning (0.00 sec)
mysql> set character_set_database=utf8;
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> set character_set_server=utf8;
Query OK, 0 rows affected (0.00 sec)
mysql> show variables like ‘char%’;
±-------------------------±--------------------------------------------+
| Variable_name | Value |
±-------------------------±--------------------------------------------+
| character_set_client | gbk |
| character_set_connection | gbk |
| character_set_database | utf8 |
| character_set_filesystem | binary |
| character_set_results | gbk |
| character_set_server | utf8 |
| character_set_system | utf8 |
| character_sets_dir | E:\environment\mysql-5.7.19\share\charsets\ |
±-------------------------±--------------------------------------------+
8 rows in set, 1 warning (0.00 sec)