mysql报错问题解决Character set 'utf8mb4' is not a compiled character set

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了mysql报错问题解决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

报错的解决方法



1、由于日常程序使用了字符集utf8mb4,为了避免每次更新时,set names utf8mb4,就把配置文件改了,如下:

增加了mysql客户端的默认字符集设置

[[email protected]~]# vim /etc/my.cnf

#my.cnf

[client]

port            = 3306

socket          = /home/mysql/mysql.sock

default-character-set=utf8mb4

2、重启mysql服务

[[email protected]~]# service mysql restart

Shutting down MySQL (Percona Server).... SUCCESS! 

Starting MySQL (Percona Server).... SUCCESS! 

3、进入mysql时,报错:

[[email protected]~]# mysql

Logging to file ‘/home/mysql/query.log‘

mysql: Character set ‘utf8mb4‘ is not a compiled character set and is not specified in the ‘/usr/share/mysql/charsets/Index.xml‘ file


4、百度了一个解决方法:

[[email protected]~]# vim /etc/my.cnf

#my.cnf

[client]

port            = 3306

socket          = /home/mysql/mysql.sock

character-sets-dir=/usr/local/Percona-Server-5.5.20-rel24.1-217.Linux.x86_64/share/charsets

default-character-set=utf8mb4


5、重启mysql后,还是报同样的错

[[email protected]~]# service mysql restart

Shutting down MySQL (Percona Server).... SUCCESS! 

Starting MySQL (Percona Server).... SUCCESS! 

[[email protected]~]# mysql

Logging to file ‘/home/mysql/query.log‘

mysql: Character set ‘utf8mb4‘ is not a compiled character set and is not specified in the ‘/usr/share/mysql/charsets/Index.xml‘ file


6、经查mysql命令调用的是/usr/bin下的

   

[[email protected] ~]# ls /usr/bin/ |grep mysql

msql2mysql

mysql

mysqlaccess

mysqladmin

mysqlbinlog

mysqlcheck

mysql_config

mysqld_multi

mysqld_safe

mysqldump

mysql_find_rows

mysqlimport

mysqlshow

mysqlslap

mysql_waitpid


7、发现该服务器上在我安装mysql5.5.20之前,安装过mysql5.1的客户端

[[email protected] ~]# rpm -qa |grep mysql

mysql-5.1.73-3.el6_5.x86_64

mysql-libs-5.1.73-3.el6_5.x86_64



8、将mysql5.5.20下的mysql命令全部拷贝到/usr/bin目录下

\cp /usr/local/Percona-Server-5.5.20-rel24.1-217.Linux.x86_64/bin/* /usr/bin/


9、5.5.20相比5.1版本增加了不少命令

[[email protected]~]# ls /usr/bin/ |grep mysql

msql2mysql

mysql

mysqlaccess

mysqlaccess.conf

mysqladmin

mysqlbinlog

mysqlbug

mysqlcheck

mysql_client_test

mysql_config

mysql_convert_table_format

mysqld

mysqld_multi

mysqld_safe

mysqldump

mysqldumpslow

mysql_find_rows

mysql_fix_extensions

mysqlhotcopy

mysqlimport

mysql_install_db

mysql_plugin

mysql_secure_installation

mysql_setpermission

mysqlshow

mysqlslap

mysqltest

mysql_tzinfo_to_sql

mysql_upgrade

mysql_waitpid

mysql_zap



10、修改完后,再次使用进入mysql,OK~


本文出自 “菜鸟地盘” 博客,请务必保留此出处http://yangjingangel.blog.51cto.com/8351501/1754413

以上是关于mysql报错问题解决Character set 'utf8mb4' is not a compiled character set的主要内容,如果未能解决你的问题,请参考以下文章

mysql报错:/usr/sbin/mysqld:unknown variable 'default-character-set=utf8'

MySQL执行外部sql脚本文件命令报错:unknown command ''

Centos7常见问题解决方案

mysql-mysqlslap执行报错

MySQL 5.5版本解决中文乱码问题时my.ini内[mysqld]项中不能再写default-character-set=utf8

MySQL:Unknown character set:utf8mb4怎么解决