mysql 在source 导入sql文件乱码问题

@admin  December 16, 2016
mysql -u root -p
> source /tmp/12.12.sql
...

上述代码插入到数据库的中文乱码。

解决方法

  • 在mysql -u -p 后加 --default-character-set=utf8
  • my.ini修改配置 default-character-set=utf8
  • mysql设置编码命令
SET character_set_client = utf8; 
SET character_set_connection = utf8; 
SET character_set_database = utf8; 
SET character_set_results = utf8;/*这里要注意很有用*/ 
SET character_set_server = utf8;
SET collation_connection = utf8_bin; 
SET collation_database = utf8_bin; 
SET collation_server = utf8_bin;

添加新评论