部分图像如下:
修改成功后重新启动mysql数据库。
Shell命令:
service mysql restart
有时候数据库service mysql start启动成功,却只能在root用mysql命令,可能是因为防火墙没有关闭,使用下面命令解决问题:
service iptables stop
然后查询字符集 :
show variables like '%character%';
show variables like "%colla%";
成功图像如下:
2.Windows下修改方法
MySQL安装目录下的my-default.ini改为my.ini文件
[client]节点
default-character-set=utf8 (增加)
[mysql]节点
default-character-set=utf8 (修改)
[mysqld]节点
character_set_server=utf8 (修改)
修改完毕后使用
net stop mysql
net start mysql
重新启动mysql服务
然后查询字符集:
show variables like '%character%';
show variables like "%colla%";
3.在使用过程中强制设置字符集编码
为确保字符集完全统一,在建表、建库的时候要强制设定统一字符集。
另外通过JDBC连接MySQL的时候为确保万无一失,连接字符串需要加上以下参数:jdbc:mysql://localhost:3306/mysql ?useUnicode=true&characterEncoding=UTF-8
以上就是mysql 中文乱码解决办法的详细内容!
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://haodehen.cn/did93282
mysql 中文乱码解决办法
阅读:52次