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/charsetsorshare/charsetsdirectory under the MySQL installation directory). This can be fixed by using the--character-sets-diroption 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.xmland 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对 ...
随机推荐
- UVA11806 Cheerleaders (容斥)
题目链接 Solution 可以考虑到总方案即为 \(C_{nm}^k\) . 考虑到要求的是边缘都必须至少有 \(1\) ,所以考虑不合法的. 第一行和最后一行没有的方案即为 \(C_{(n-1)m ...
- 寻找web根目录
有时候,在利用一些命令执行漏洞时,可以以较高权限执行一些操作,但在我们想要上传shell的时候,却找不到网站根目录,下面是一些日常使用的寻找网站根目录的方法,记录下: 1.jsp 查看当前路径,在这个 ...
- JS 改变鼠标样式
此片记录如何改变鼠标样式: document.body.style.cursor = "url(resource/pic/icons/magnifier3.cur) 12 12,crossh ...
- [LeetCode] Merge Intervals 排序sort
Given a collection of intervals, merge all overlapping intervals. For example,Given [1,3],[2,6],[8,1 ...
- Android build code command
make bootimage -j8 make systemimage -j8
- 大话tomcat之tomcat连接mysql
研究主题:tomcat连接mysql 一.tomcat连接mysql的两种连接方式:简单连接(不使用连接池)使用tomcat连接池 二.简单分析:(简介部分摘自一篇博客,觉得写得非常赞,读了非常有快感 ...
- 三个div向左浮动不在同一行,向右浮动在同一行的解决办法
前几天在写代码的时候发现了一个问题,问题的大致描述如下: 在一个大的div中,同一行有三个小的div,当三个小的div均向左浮动时,会出现换行问题,均向右浮动时却在同一行. 解决这个问题的方法是在:在 ...
- WSL学习:安装ArchLinux和Root/Cling以及注意事项
1.前言 在Windows下使用Linux常见的软件存在许多困难.选择之一是使用VMWare和VirtualBox之类的虚拟机软件,另一种选择是使用类UNIX模拟环境,如Cygwin,GNUWin32 ...
- Python_代码练习_写一个判断是否为小数的函数
这两天在学习函数,练习写一个判断是否为小数的函数,看起来蛮简单的,飞速写完很是得意,然后测了一下,发现差得好多呀,这个并不像想象那样简单,我得到的教训是,想要把一个需求哪怕再小的需求考虑周全,都不是件 ...
- hdu 5020(斜率的表示+STL)
Revenge of Collinearity Time Limit: 8000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/ ...