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客户端的默认字符集设置

[root@~]# vim /etc/my.cnf

#my.cnf

[client]

port            = 3306

socket          = /home/mysql/mysql.sock

default-character-set=utf8mb4

2、重启mysql服务

[root@~]# service mysql restart

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

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

3、进入mysql时,报错:

[root@~]# 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、百度了一个解决方法:

[root@~]# 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后,还是报同样的错

[root@~]# service mysql restart

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

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

[root@~]# 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下的

   

[root@ ~]# 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的客户端

[root@ ~]# 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版本增加了不少命令

[root@~]# 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~