修改mysql默认字符集的方法
时间:2021-07-01 10:21:17
帮助过:25人阅读
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 collation_connection = utf8 ;
mysql> SET collation_database = utf8 ;
mysql> SET collation_server = utf8 ;
一般就算设置了表的mysql默认字符集为utf8并且通过UTF-8编码发送查询,你会发现存入数据库的仍然是乱码。问题就出在这个connection连接层上。解决方法是在发送查询前执行一下下面这句:
- SET NAMES ‘utf8‘;
它相当于下面的三句指令:
- SET character_set_client = utf8;
- SET character_set_results = utf8;
- SET character_set_connection = utf8;
修改mysql默认字符集的方法
标签:重启 字符 href set 查询 var 数据库 dir show