innobackupex 备份时utf8mb4编码的mysql数据库失败

现象:

备份时出现如下错误:

[root@UHDEV014 wxc]# innobackupex --defaults-file=/etc/my_new.cnf --user=root --password=xxxxx--port=3307 --slave-info --safe-slave-backup --socket=/export/mysql_new/sock/mysql.sock --no-timestamp /apps/wxc/back3307
InnoDB Backup Utility v1.5.1-xtrabackup; Copyright 2003, 2009 Innobase Oy
and Percona LLC and/or its affiliates 2009-2013.  All Rights Reserved.
This software is published under
the GNU GENERAL PUBLIC LICENSE Version 2, June 1991.
Get the latest version of Percona XtraBackup, documentation, and help resources:
http://www.percona.com/xb/p

170113 14:24:58  innobackupex: Executing a version check against the server...
170113 14:24:58  innobackupex: Connecting to MySQL server with DSN 'dbi:mysql:;mysql_read_default_file=/etc/my_new.cnf;mysql_read_default_group=xtrabackup;port=3307;mysql_socket=/export/mysql_new/sock/mysql.sock' as 'root'  (using password: YES).
Character set 'utf8mb4' is not a compiled character set and is not specified in the '/usr/share/mysql/charsets/Index.xml' file
innobackupex: got a fatal error with the following stacktrace: at /usr/bin/innobackupex line 3011
        main::mysql_connect('abort_on_error', 1) called at /usr/bin/innobackupex line 1551
innobackupex: Error: Failed to connect to MySQL server: DBI connect(';mysql_read_default_file=/etc/my_new.cnf;mysql_read_default_group=xtrabackup;port=3307;mysql_socket=/export/mysql_new/sock/mysql.sock','root',...) failed: Can't initialize character set utf8mb4 (path: /usr/share/mysql/charsets/) at /usr/bin/innobackupex line 2995
170113 14:24:58  innobackupex: Connecting to MySQL server with DSN 'dbi:mysql:;mysql_read_default_file=/etc/my_new.cnf;mysql_read_default_group=xtrabackup;port=3307;mysql_socket=/export/mysql_new/sock/mysql.sock' as 'root'  (using password: YES).
Character set 'utf8mb4' is not a compiled character set and is not specified in the '/usr/share/mysql/charsets/Index.xml' file
innobackupex: got a fatal error with the following stacktrace: at /usr/bin/innobackupex line 3011
        main::mysql_connect('abort_on_error', 1) called at /usr/bin/innobackupex line 1570
innobackupex: Error: Failed to connect to MySQL server: DBI connect(';mysql_read_default_file=/etc/my_new.cnf;mysql_read_default_group=xtrabackup;port=3307;mysql_socket=/export/mysql_new/sock/mysql.sock','root',...) failed: Can't initialize character set utf8mb4 (path: /usr/share/mysql/charsets/) at /usr/bin/innobackupex line 2995


原因:

innobackupex连接数据库时,默认的字符集为utf8,但是my_new.cnf


解决方法:修改/etc/my_new.cnf文件中的如下内容:

[client]
default-character-set=utf8

你可能感兴趣的:(mysql)