解决centOS上数据库插入中文显示???的问题
2017-02-13 15:27
323 查看
使用show variables like 'character_set%';查看数据库的各种字符集参数
eg:
+--------------------------+----------------------------+
| Variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | utf8 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | latin1 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
可以看到character_set_server 一项是latin1
修改/etc/my.cnf文件,在[mysqld]一行下增加character-set-server=utf8配置项,如果etc目录下没有该文件,从目
录/usr/share/mysql/中拷贝my-default.cnf到etc目录下改名为my.cnf即可。
eg:(这是我的my.cnf)
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html
# *** DO NOT EDIT THIS FILE. It's a template which will be copied to the
# *** default location during install, and will be replaced if you
# *** upgrade to a newer version of MySQL.
[mysqld]
character-set-server=utf8
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
# These are commonly set, remove the # and set as required.
# basedir = .....
# datadir = .....
# port = .....
# server_id = .....
# socket = .....
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
然后再用show variables like 'character_set%';进行查询
+--------------------------+----------------------------+
| Variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | utf8 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | utf8 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
OK.问题解决
eg:
+--------------------------+----------------------------+
| Variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | utf8 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | latin1 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
可以看到character_set_server 一项是latin1
修改/etc/my.cnf文件,在[mysqld]一行下增加character-set-server=utf8配置项,如果etc目录下没有该文件,从目
录/usr/share/mysql/中拷贝my-default.cnf到etc目录下改名为my.cnf即可。
eg:(这是我的my.cnf)
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html
# *** DO NOT EDIT THIS FILE. It's a template which will be copied to the
# *** default location during install, and will be replaced if you
# *** upgrade to a newer version of MySQL.
[mysqld]
character-set-server=utf8
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
# These are commonly set, remove the # and set as required.
# basedir = .....
# datadir = .....
# port = .....
# server_id = .....
# socket = .....
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
然后再用show variables like 'character_set%';进行查询
+--------------------------+----------------------------+
| Variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | utf8 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | utf8 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
OK.问题解决
相关文章推荐
- 解析linux patch(解决报错./stdio.h:456:1: error: 'gets' undeclared here (not in a function))
- linux中KS详解
- linux中KS详解
- 怎么在linux下俘获程序奔溃时的调用堆栈
- linux 下打包命令
- linux第一次登录root,设置root密码
- linux下python安装
- LINUX内核经典面试题
- Centos安装jre-8u121-linux-x64.tar.gz
- CentOS6.5升级autoconf版本,解决”Autoconf version 2.64 or higher is required“错误
- Linux下进程间通信
- Linux 上配置 NTP SERVER
- linux操作记录
- linux下使用命令修改IP地址
- Linux下javaweb环境搭建
- CentOS7.2部署FTP
- (转)linux设备驱动之USB数据传输分析 二
- 手把手教你安装使用dokuwiki [CentOs系统]
- (转)linux设备驱动之USB数据传输分析 一
- linux下打开windows txt文件中文乱码问题