mysql 字符集
来源:互联网 发布:淘宝卖家刷钻 编辑:程序博客网 时间:2024/06/05 04:20
乱码
问题描述
乱码,一般是中文乱码。
原因分析
MySQL会出现中文乱码的原因不外乎下列几点:
1.server本身设定问题,例如还停留在latin1
2.table的语系设定问题(包含character与collation)
3.客户端程式(例如php)的连线语系设定问题
http://blog.csdn.net/luoweifu/article/details/8832492
解决方法
修改字符集。
修改字符集
问题描述
之前以为修好mysql的字符集是用set命令,今天发现用set命令设置字符集之后,如果重启mysql的话,结果又是和配置文件里的字符集是一样的,而不是刚刚用set命令设置的字符集。换句话说,set命令设置字符集只是暂时起作用,一旦重启mysql之后,就又恢复到之前的字符集。
原因分析
同上。
解决方法
那么,该如何修改mysql的字符集呢?只有在配置文件里修改咯,并且修改完之后,要重启mysql。
具体怎么修改?
1、windows版本
修改配置文件里的字符集。
修改2个地方,一个是mysql服务器本身的字符集,一个是客户端的字符集(客户端字符集是干嘛的?待研究!)。
# CLIENT SECTION# ----------------------------------------------------------------------## The following options will be read by MySQL client applications.# Note that only client applications shipped by MySQL are guaranteed# to read this section. If you want your own MySQL client program to# honor these values, you need to specify it as an option during the# MySQL client library initialization.#[client]port=3306[mysql]default-character-set=utf8
# SERVER SECTION# ----------------------------------------------------------------------## The following options will be read by the MySQL Server. Make sure that# you have installed the server correctly (see above) so it reads this # file.#[mysqld]# The TCP/IP Port the MySQL Server will listen onport=3306#Path to installation directory. All paths are usually resolved relative to this.basedir="C:/Program Files (x86)/MySQL/MySQL Server 5.5/"#Path to the database rootdatadir="C:/ProgramData/MySQL/MySQL Server 5.5/Data/"# The default character set that will be used when a new schema or table is# created and no character set is definedcharacter-set-server=utf8
2、linux版本
没看到配置文件里有字符集,所以添加一个字符集。
只需添加一个地方,那就是mysql服务器的字符集。
[mysqld]# Settings user and group are ignored when systemd is used (fedora >= 15).# If you need to run mysqld under different user or group, # customize your systemd unit file for mysqld according to the# instructions in http://fedoraproject.org/wiki/Systemduser=mysqlcharacter_set_server = utf8datadir=/var/lib/mysqlsocket=/var/lib/mysql/mysql.sock
注:不论是修改字符集,还是添加字符集,都不要放错了地方,而应该放在对应的mysql服务器配置段落或者客户端配置段落,否则重启mysql时可能会重启失败。
0 0
- mysql 字符集
- mysql 字符集
- mysql字符集
- mysql 字符集
- Mysql 字符集
- MySQL字符集
- Mysql字符集
- mysql字符集
- MySQL字符集
- mysql字符集
- Mysql字符集
- Mysql字符集
- mysql字符集
- Mysql 字符集
- MYSQL字符集
- mysql字符集
- mysql字符集
- mysql字符集
- XML配置Spring注解
- 总结关于管理数据库和表的知识点
- 使用remi仓库安装最新版本的redis
- eclipse中Tomcat环境配置
- dubbo
- mysql 字符集
- Oracle基本数据类型
- python flask 学习笔记1 简单入门
- Mysql 日志
- WinCE6.0+S3C6410 USB驱动架构分析
- 福建省赛 RunningMan fzoj2221
- ReentrantLock对AQS的使用代码分析
- 某类线段树的复杂度分析
- 【C++11】新特性——auto的使用