博客
关于我
mysql字符集设置
阅读量:794 次
发布时间:2023-02-12

本文共 486 字,大约阅读时间需要 1 分钟。

配置文件路径:/full/path/mysql/bin/my.cnf (默认为/etc/my.cnf )

[client]默认字符集设置为utf8

[mysql]默认字符集设置为utf8

[mysqld]初始化连接设置为{'SET collation_connection = utf8_unicode_ci'}

初始化连接设置为{'SET NAMES utf8'}
字符集设置为utf8
collation-server设置为utf8_unicode_ci
skip-character-set-client-handshake

查看MySQL编码方式:show variables like 'character%';

其中:

character_set_client:客户端编码方式
character_set_connection:连接使用的编码
character_set_database:数据库编码
character_set_results:结果集编码
character_set_server:服务器编码

只要确保以上四个编码方式一致,就能避免乱码问题。

转载地址:http://gebfk.baihongyu.com/

你可能感兴趣的文章