Home > Database > Mysql Tutorial > body text

MySQL字符集编码的理解

WBOY
Release: 2016-06-07 16:18:10
Original
706 people have browsed it

无论在客户机用哪个版本的mysql客户端连接服务器,发现只要服务器端设置了 character-set-server = utf8之后, character_set_client、 character_set_connection、character_set_results 就始终都是和服务器端保持一致了,即便在mysql客户端加上选项 --defa

   无论在客户机用哪个版本的mysql客户端连接服务器,发现只要服务器端设置了

  character-set-server = utf8之后,

  character_set_client、 character_set_connection、character_set_results

  就始终都是和服务器端保持一致了,即便在mysql客户端加上选项

  --default-character-set=utf8

  也不行,除非连接进去后,再手工执行命令

  set names latin1,才会将client、connection、results的字符集改过来。

  经过仔细对比,最终发现让我踩坑的地方是,服务器端设置了另一个选项:

  skip-character-set-client-handshake

  文档上关于这个选项的解释是这样的:

  --character-set-client-handshake

  Don't ignore character set information sent by the client. To ignore client information and use the default server character set, use --skip-character-set-client-handshake; this makes MySQL behave like MySQL 4.0

  这么看来,,其实也是有好处的。比如启用 skip-character-set-client-handshake 选项后,就可以避免客户端程序误操作,使用其他字符集连接进来并写入数据,从而引发乱码问题。

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!