0 0

linux 下在终端中直接网mysql 插入中文出错,这是我的my.cnf 文件和字符编码显示结果.5

#
# The MySQL database server configuration file.
#
# You can copy this to one of:
# - "/etc/mysql/my.cnf" to set global options,
# - "~/.my.cnf" to set user-specific options.
#
# One can use all long options that the program supports.
# Run program with --help to get a list of available options and with
# --print-defaults to see which it would actually understand and use.
#
# For explanations see
# http://dev.mysql.com/doc/mysql/en/server-system-variables.html

# This will be passed to all mysql clients
# It has been reported that passwords should be enclosed with ticks/quotes
# escpecially if they contain "#" chars...
# Remember to edit /etc/mysql/debian.cnf when changing the socket location.
[client]
port = 3306
socket = /var/run/mysqld/mysqld.sock
default-character-set=utf8

# Here is entries for some specific programs
# The following values assume you have at least 32M ram

# This was formally known as [safe_mysqld]. Both versions are currently parsed.
[mysqld_safe]
socket = /var/run/mysqld/mysqld.sock
nice = 0

[mysqld]
#
# * Basic Settings
#
user = mysql
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
character-set-server=utf8
port = 3306
basedir = /usr
datadir = /var/lib/mysql
tmpdir = /tmp
lc-messages-dir = /usr/share/mysql
skip-external-locking
#
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
bind-address = 127.0.0.1
#
# * Fine Tuning
#
key_buffer = 16M
max_allowed_packet = 16M
thread_stack = 192K
thread_cache_size       = 8
# This replaces the startup script and checks MyISAM tables if needed
# the first time they are touched
myisam-recover         = BACKUP
#max_connections        = 100
#table_cache            = 64
#thread_concurrency     = 10
#
# * Query Cache Configuration
#
query_cache_limit = 1M
query_cache_size        = 16M
#
# * Logging and Replication
#
# Both location gets rotated by the cronjob.
# Be aware that this log type is a performance killer.
# As of 5.1 you can enable the log at runtime!
#general_log_file        = /var/log/mysql/mysql.log
#general_log             = 1
#
# Error log - should be very few entries.
#
log_error = /var/log/mysql/error.log
#
# Here you can see queries with especially long duration
#log_slow_queries = /var/log/mysql/mysql-slow.log
#long_query_time = 2
#log-queries-not-using-indexes
#
# The following can be used as easy to replay backup logs or for replication.
# note: if you are setting up a replication slave, see README.Debian about
#       other settings you may need to change.
#server-id = 1
#log_bin = /var/log/mysql/mysql-bin.log
expire_logs_days = 10
max_binlog_size         = 100M
#binlog_do_db = include_database_name
#binlog_ignore_db = include_database_name
#
# * InnoDB
#
# InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/.
# Read the manual for more InnoDB related options. There are many!
#
# * Security Features
#
# Read the manual, too, if you want chroot!
# chroot = /var/lib/mysql/
#
# For generating SSL certificates I recommend the OpenSSL GUI "tinyca".
#
# ssl-ca=/etc/mysql/cacert.pem
# ssl-cert=/etc/mysql/server-cert.pem
# ssl-key=/etc/mysql/server-key.pem

[mysqldump]
quick
quote-names
max_allowed_packet = 16M

[mysql]
#no-auto-rehash # faster start of mysql but no tab completition
default-character-set=utf8
[isamchk]
key_buffer = 16M

#
# * IMPORTANT: Additional settings that can override those from this file!
#   The files must end with '.cnf', otherwise they'll be ignored.
#
!includedir /etc/mysql/conf.d/





mysql> SHOW VARIABLES LIKE 'char%';
+--------------------------+----------------------------+
| Variable_name            | Value                      |
+--------------------------+----------------------------+
| character_set_client     | utf8                       |
| character_set_connection | utf8                       |
| character_set_database   | latin1                     |
| character_set_filesystem | binary                     |
| character_set_results    | utf8                       |
| character_set_server     | utf8                       |
| character_set_system     | utf8                       |
| character_sets_dir       | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
8 rows in set (0.00 sec)








2014年7月24日 11:45

2个答案 按时间排序 按投票排序

0 0

在终端执行以下命令:
tee /etc/mysql/conf.d/utf8_charset.cnf 1>/dev/null <<MYSQL_CONFIG
[mysqld]
character_set_server = utf8
collation_server = utf8_general_ci
max_allowed_packet=64M
MYSQL_CONFIG

mysql -e "SET GLOBAL character_set_server=utf8;"
mysql -e "SET GLOBAL collation_server=utf8_general_ci;"

2014年7月25日 12:27
0 0

那就采用命令行的方式来修改,分别修改server、database、table默认的字符集

引用
mysql> use callcenter; 
Reading table information for completion of table and column names 
You can turn off this feature to get a quicker startup with -A 
 
Database changed 
 
mysql> alter database callcenter character set utf8; 
Query OK, 1 row affected (0.00 sec) 
 
mysql> set names 'utf8'; 
Query OK, 0 rows affected (0.00 sec) 
 
mysql> use callcenter; 
Database changed 
mysql> select * from um_group; 
+----+------+----------------+------+ 
| id | name | description    | type | 
+----+------+----------------+------+ 
|  1 | ??   | ?????????????  |    2 | 
|  2 | ???  | ?????????????? |    2 | 
|  3 | aaaa | aaaaaa         |    2 | 
|  3 | ??   | ??             |    2 | 
|  4 | ??   | ??             |    2 | 
|  5 | ??   | ??             |    2 | 
+----+------+----------------+------+ 
6 rows in set (0.00 sec) 
 
mysql> select * from test; 
+----+------+-------------+------+ 
| id | name | description | type | 
+----+------+-------------+------+ 
|  5 | ??   | ??          |    2 | 
+----+------+-------------+------+ 
1 row in set (0.00 sec) 
 
mysql> show variables like 'character_%'; 
+--------------------------+----------------------------+ 
| 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/ | 
+--------------------------+----------------------------+ 
8 rows in set (0.00 sec) 
 
mysql> set character_set_server=utf8; 
Query OK, 0 rows affected (0.00 sec) 
 
mysql> select * from test; 
+----+------+-------------+------+ 
| id | name | description | type | 
+----+------+-------------+------+ 
|  5 | ??   | ??          |    2 | 
|  6 | ??   | ??          |    2 | 
+----+------+-------------+------+ 
2 rows in set (0.00 sec) 
 
mysql> drop table test; 
Query OK, 0 rows affected (0.04 sec) 
 
mysql> create table test( 
    -> name varchar(20) 
    -> ); 
Query OK, 0 rows affected (0.04 sec) 
 
mysql> insert into test values('啊啊啊'); 
Query OK, 1 row affected (0.00 sec) 
 
mysql> select * from test; 
+-----------+ 
| name      | 
+-----------+ 
| 啊啊啊 | 
+-----------+ 
1 row in set (0.00 sec) 

2014年7月24日 12:51

相关推荐

    linux下mysql my.cnf 文件

    linux下mysql my.cnf 文件已经配置好 路径根据实际情况自己修改linux下mysql my.cnf 文件已经配置好 路径根据实际情况自己修改linux下mysql my.cnf 文件已经配置好 路径根据实际情况自己修改

    MySQL各版本my.cnf配置文件.rar

    MySQL 5.6、5.7、8.0版本的my.cnf完整配置文件,亲测可用,配置文件中优化了MySQL中的一些默认配置项,能够有效的提高MySQL数据库的并发处理能力!

    mysql-5.7.24的my.cnf

    mysql-5.7.24的my.cnf。适用于生产环境。相关配置已经写好,直接可以用。 mysql-5.7.24的my.cnf。适用于生产环境。相关配置已经写好,直接可以用。 mysql-5.7.24的my.cnf。适用于生产环境。相关配置已经写好,直接...

    Linux MySQL基础配置文件my.cnf

    Linux环境, 通过编辑my.cnf文件,设置MySQL数据库字符集,centos6.5 安装MySQL 5.7.21 ,没有找到my.cnf文件,此文件为基础配置文件

    mysql数据库my.cnf配置文件

    #MySQL的查询缓冲大小(从4.0.1开始,MySQL提供了查询缓冲机制)使用查询缓冲,MySQL将SELECT语句和查询结果存放在缓冲区中, # 今后对于同样的SELECT语句(区分大小写),将直接从缓冲区中读取结果。根据MySQL用户...

    linux下mysql配置文件my.cnf详解.pdf

    linux下mysql配置文件my.cnf详解.pdf linux下mysql配置文件my.cnf详解.zip dba基础

    MySQL中my.cnf文件选项

    MySQL中my.cnf文件选项 MySQL中my.cnf文件选项 MySQL中my.cnf文件选项

    mysql5.7用的配置文件my.cnf

    mysql5.7用的配置文件,完成了基本的调优选项,并注释了需要自行调整参数的计算公式,使用时请自行重命名为my.cnf。如配合我上传的自动安装脚步mysql7install.sh一起使用则无需重命名,配置在对应的http服务上使用...

    mysql linux 下配置my.cnf

    mysql linux 下配置my.cnfmysql linux 下配置my.cnfmysql linux 下配置my.cnf

    linux下mysql配置文件my.cnf详解

    linux下mysql配置文件my.cnf详解

    MySQL 8.0 的详细 配置 my.cnf

    MySQL 教程 MySQL 是最流行的关系型数据库管理系统,在 WEB 应用方面 MySQL 是最好的 RDBMS(Relational Database Management System:关系数据库 MySQL8.0数据库的一般配置 Linux环境的配置文件

    mysql数据库my.cnf配置文件注释详解

    mysql数据库my.cnf配置文件注释详解

    mysql5.7 my.cnf配置文件优化

    mysql5.7优化后的配置文件,mysql5.7主从架构配置环境,生产环境直接使用,推荐生产环境5.7版本使用最稳定版本5.7.21。

    CentOS7下MySQL8的主主互备安装文档和my.cnf配置文件

    CentOS7操作系统在VM虚拟机下的安装,MySQL8.0.13在CentOS7下的主主互备,以及附带my.cnf的详细配置,带有注释。

    MySQL中配置文件my.cnf因权限问题导致无法启动的解决方法

    本文主要给大家介绍了关于MySQL中配置文件my.cnf因权限问题导致无法启动的相关解决过程,分享出来供大家参考学习,下面来一起看看详细的介绍: 问题描述 MySQL 无法启动,报如下错误: 问题分析 查看 MySQL 错误...

    MySQL配置文件my.cnf中文版

    MySQL配置文件my.cnf中文版.doc

    ubuntu mysql my.cnf 服务器最佳配置

    ubuntu mysql my.cnf 服务器最佳配置(16G,32G 内存)

    mysql配置文件my.cnf

    mysql配置文件my.cnf,经常由于mysql升级后,默认没有此配置文件,上传以备份,根据个人需求,手动修改改文件,放置于/etc/my.cnf处,重启mysql生效

    mysql配置,通用my.cnf文件

    MySQL5.6 数据库配置文件my.cnf,内容详细解释了各个配置。根据个人安装路径,手动修改资源中相应的路径即可使用。

    修改my.cnf之后启动mysql出错(完美解决).docx

    记录我的学习之旅,每份文档倾心倾力,带我成我大牛,回头观望满脸笑意,望大家多多给予意见,有问题或错误,请联系 我将及时改正;借鉴文章标明出处,谢谢

Global site tag (gtag.js) - Google Analytics