Character set 'utf8mb4' is not a compiled character set
近期在一次MySQL数据迁移的过程中遭遇了字符集的问题,提示为"Character set 'utf8mb4' is not a compiled character set"。即是字符集utf8mb4不是一个编译的字符集以及没有在Index.xml文件中指定。以下是其处理过程及解决的方法。供大家參考。
1、错误提示
SHELL> mysqlbinlog --database=bs_salary --stop-datetime="2014-12-15 8:24:48" /home/robin/mysql-bin.000399 \
> |mysql -uroot -p --force --database=salary_1215
mysql: Character set 'utf8mb4' is not a compiled character set and is not specified in the '/usr/share/mysql/charsets/Index.xml' file
2、分析与解决
a、错误分析
从给出的错误提示来看,说utf8mb4字符集未被编译。而其实这个字符集根本没实用到。
其次说这个文件中/usr/share/mysql/charsets/Index.xml未指定utf8mb4字符集,须要检查字符集文件夹设置。
b、字符集检查
首先检查了新旧环境的字符集设置。两边都为UTF8,例如以下
mysql> show variables like '%char%';
+--------------------------+---------------------------------+
| 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 | /app/soft/mysql/share/charsets/ |
+--------------------------+---------------------------------+
# Author : Leshami
# Blog : http://blog.csdn.net/leshami
c、服务器字符集路径设置
对于字符集的路径设置,与错误提示不一致。尝试改动器配置文件
SHELL> tail -3 /etc/my.cnf
[client]
#default-character-set=utf8
character-sets-dir=/app/soft/mysql/share/charsets/
改动配置文件后再次碰到错误提演示样例如以下,因此字符集路径不是主要原因
mysql: Character set 'utf8mb4' is not a compiled character set and is not specified in the '/app/soft/mysql/share/charsets/Index.xml' file
SHELL> /app/soft/mysql/share/charsets/Index.xml /app/soft/mysql/share/charsets/Index.xml.bk
d、加入utf8mb4字符集到Index.xml
直接复制utf8的配置。改为utf8mb4后。加入到/app/soft/mysql/share/charsets/Index.xml故障解决。
<charset name="utf8mb4">
<family>Unicode</family>
<description>UTF-8 Unicode</description>
<alias>utf-8</alias>
<collation name="utf8_general_ci" id="33">
<flag>primary</flag>
<flag>compiled</flag>
</collation>
<collation name="utf8_bin" id="83">
<flag>binary</flag>
<flag>compiled</flag>
</collation>
</charset>
3、MySQL官方解释
https://dev.mysql.com/doc/refman/5.5/en/charset-configuration.html
If you try to use a character set that is not compiled into your binary, you might run into the following problems:
Your program uses an incorrect path to determine where the character sets are stored (which is typically the
share/mysql/charsets
orshare/charsets
directory under the MySQL installation directory). This can be fixed by using the--character-sets-dir
option when you run the program in question. For example, to specify a directory to be used by MySQL client programs, list it in the[client]
group of your option file. The examples given here show what the setting might look like for Unix or Windows, respectively:[client]
character-sets-dir=/usr/local/mysql/share/mysql/charsets [client]
character-sets-dir="C:/Program Files/MySQL/MySQL Server 5.5/share/charsets"The character set is a complex character set that cannot be loaded dynamically. In this case, you must recompile the program with support for the character set.
For Unicode character sets, you can define collations without recompiling by using LDML notation. See Section 10.4.4, “Adding a UCA Collation to a Unicode Character Set”.
The character set is a dynamic character set, but you do not have a configuration file for it. In this case, you should install the configuration file for the character set from a new MySQL distribution.
If your character set index file does not contain the name for the character set, your program displays an error message. The file is named
Index.xml
and the message is:Character set '
charset_name
' is not a compiled character set and is not
specified in the '/usr/share/mysql/charsets/Index.xml' fileTo solve this problem, you should either get a new index file or manually add the name of any missing character sets to the current file.
You can force client programs to use specific character set as follows:
[client]
default-character-set=charset_name
This is normally unnecessary. However, when character_set_system
differs from character_set_server
or character_set_client
, and you input characters manually (as database object identifiers, column values, or both), these may be displayed incorrectly in output from the client or the output itself may be formatted incorrectly. In such cases, starting the mysql client with --default-character-set=
—that is, setting the client character set to match the system character set—should fix the problem.system_character_set
从上面的描写叙述来看我这个情形。提示的路径与character-sets-dir路劲不一致。通过改动配置文件后,保持了一致。
找到缺省的Index.xml配置文件是因为多版本号的问题。二是不清楚为什么要加入utf8mb4这个配置到index.xml文件,根本没用到这个字符集。我预计是要所有检測一遍。尽管加入可用了,可是还是感觉不那么可靠。
Character set 'utf8mb4' is not a compiled character set的更多相关文章
- MySQL报错: Character set ‘utf8mb4‘ is not a compiled character set and is not specified in the ‘/usr/share/mysql/charsets/Index.xml‘ file
由于日常程序使用了字符集utf8mb4,为了避免每次更新时,set names utf8mb4,就把配置文件改了,如下: [root@~]# vim /etc/my.cnf #my.cnf [clie ...
- mysql: Character set 'utf8mb4' is not a compiled character set and is not specified in the '/usr/share/mysql/charsets/Index.xml' file
mysql: Character set 'utf8mb4' is not a compiled character set and is not specified in the '/usr/sha ...
- Unknown initial character set index '255' received from server. Initial client character 解决方法
Unknown initial character set index '255' received from server. Initial client character set can be ...
- Non-ASCII character '\xe8' in file xxx.py on line 8, but no encoding declared
使用网上某个python程序.编译时报错: File "xxx.py", line 8 SyntaxError: Non-ASCII character '\xe8 ...
- 使用gridlayout布局后,因某些原因又删除,并整理文件夹结构时,Unable to resolve target 'android-7'
出现的问题 [2013-01-11 10:52:39 - gridlayout_v7] Unable to resolve target 'android-7' 事由:在一次做九宫格时.误使用了gri ...
- 追索权 Eclipse + NDK error: stray '\24' in program
[size=16px][b][color=#FF0000]追索权 Eclipse + NDK error: stray '\24' in program[/color][b][/b][/b][/si ...
- 错误号码2003 Can't connect to MySQL server 'localhost' (0)
错误描写叙述 错误原因 近期,我一直都能够用SQLyog连接本地数据库,可是近几天却无法连接:而且一直都报上述错误,我查阅了非常多资料,发现有非常多中说法 总结一下 第一,MySQL中的my.ini出 ...
- Error creating bean with name 'menuController': Injection of autowired dependency……
出现了一大串错误 Error creating bean with name 'userController': Injection of autowired dependencies failed. ...
- IE8下提示'console'没有定义错误
在开发的过程中因为调试的原因,在代码中增加console.info("xxxx"),而未进行删除 在IE8下測试该代码所在的页面报错,例如以下: 须要注意的是,使用console对 ...
随机推荐
- 刷题总结——Genghis Khan the Conqueror (hdu4126)
题目: Genghis Khan(成吉思汗)(1162-1227), also known by his birth name Temujin(铁木真) and temple name Taizu(元 ...
- Manthan, Codefest 16 B 数学
B. A Trivial Problem time limit per test 2 seconds memory limit per test 256 megabytes input standar ...
- Ant自动打包
在ant的官网http://ant.apache.org进行下载后apache-ant-1.8.2包 解压(存放的路径不要有中文字符) 把ant里的lib设置到环境变量:E:\Android\apac ...
- linux之参数实用讲解
<1>linux文件参数 在Windows下是使用 %1 %2 %3 而在Linux下是使用 $1 $2 $3 ------------------- 如: 1.某bat文件 cd ...
- BZOJ 3910: 火车
3910: 火车 Time Limit: 20 Sec Memory Limit: 512 MBSubmit: 358 Solved: 130[Submit][Status][Discuss] D ...
- POJ3170 Bzoj1671 [Usaco2005 Dec]Knights of Ni 骑士
1671: [Usaco2005 Dec]Knights of Ni 骑士 Time Limit: 5 Sec Memory Limit: 64 MBSubmit: 281 Solved: 180 ...
- 【CF1043B】Lost Array(枚举)
题意:给定n与数组a,求所有的k使得存在x数组能按以下规则构造出a n<=1e3,a[i]<=1e6 思路: #include<cstdio> #include<cstr ...
- 《Linux命令行与shell脚本编程大全 第3版》Linux命令行---53
以下为阅读<Linux命令行与shell脚本编程大全 第3版>的读书笔记,为了方便记录,特地与书的内容保持同步,特意做成一节一次随笔,特记录如下:
- delphi 内存泄露 分析
- python 编码问题之终极解决
结合之前遇到的坑以及下面贴的这篇文章, 总结几种python乱码解决方案,如果遇到乱码,不妨尝试一下? 1,必备 #encoding=utf-8 2, python编程环境编码 import sys ...