Xtrabackup备份报错Failed to connect to MySQL server
发表于:2026-11-01 作者:千家信息网编辑
千家信息网最后更新 2026年11月01日,Xtrabackup备份报错/backup> innobackupex --defaults-file=/etc/my.cnf --user=root --password='xxxxx' /back
千家信息网最后更新 2026年11月01日Xtrabackup备份报错Failed to connect to MySQL serverXtrabackup备份报错
/backup> innobackupex --defaults-file=/etc/my.cnf --user=root --password='xxxxx' /backup/20170803
170421 18:15:39 innobackupex: Starting the backup operation
IMPORTANT: Please check that the backup run completes successfully.
At the end of a successful backup run innobackupex
prints "completed OK!".
170421 18:15:39 version_check Connecting to MySQL server with DSN 'dbi:mysql:;mysql_read_default_group=xtrabackup' as 'root' (using password: YES).
170421 18:15:39 version_check Connected to MySQL server
170421 18:15:39 version_check Executing a version check against the server...
170421 18:15:39 version_check Done.
170421 18:15:39 Connecting to MySQL server host: localhost, user: root, password: set, port: 0, socket: (null)
Failed to connect to MySQL server: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2).
仔细检查,发现输入的用户名和密码都是正确的,而且可以正常连接到数据库
/backup/MySQL_Backup/bin> mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 12
Server version: 5.6.21-70.1-log Percona Server (GPL), Release 70.1, Revision 698
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
报错原因:
在配置文件中没有配置socket
Xtrabackup在备份时,会使用本地的socket连接到数据库
解决方法:
在配置文件中增加socket选项
[root@localhost bin]# cat /etc/my.cnf
[mysqld]
basedir = /usr
datadir = /var/lib/mysql
log-error = /var/lib/mysql/localhost.localdomain.err
pid-file = /var/lib/mysql/localhost.localdomain.pid
#port = 3306
socket = /var/lib/mysql/mysql.sock
之后重启数据库,可以正常备份
/backup> innobackupex --defaults-file=/etc/my.cnf --user=backup --password='backup' /backup/20170803
170421 18:34:54 innobackupex: Starting the backup operation
IMPORTANT: Please check that the backup run completes successfully.
At the end of a successful backup run innobackupex
prints "completed OK!".
170421 18:34:54 version_check Connecting to MySQL server with DSN 'dbi:mysql:;mysql_read_default_group=xtrabackup;mysql_socket=/var/lib/mysql/mysql.sock' as 'backup' (using password: YES).
170421 18:34:54 version_check Connected to MySQL server
170421 18:34:54 version_check Executing a version check against the server...
170421 18:34:54 version_check Done.
170421 18:34:54 Connecting to MySQL server host: localhost, user: backup, password: set, port: 0, socket: /var/lib/mysql/mysql.sock
Using server version 5.6.21-70.1-log
innobackupex version 2.4.4 based on MySQL server 5.7.13 Linux (x86_64) (revision id: df58cf2)
xtrabackup: uses posix_fadvise().
xtrabackup: cd to /var/lib/mysql
xtrabackup: open files limit requested 0, set to 32768
xtrabackup: using the following InnoDB configuration:
xtrabackup: innodb_data_home_dir = .
xtrabackup: innodb_data_file_path = ibdata1:12M:autoextend
xtrabackup: innodb_log_group_home_dir = ./
xtrabackup: innodb_log_files_in_group = 2
xtrabackup: innodb_log_file_size = 50331648
InnoDB: Number of pools: 1
170421 18:34:54 >> log scanned up to (201239294)
xtrabackup: Generating a list of tablespaces
InnoDB: Allocated tablespace ID 45 for dmcdbTEST/com_numbering_plan, old maximum was 0
170421 18:34:55 >> log scanned up to (201239294)
170421 18:34:55 [01] Copying ./ibdata1 to /backup/20170803/2017-04-21_18-34-54/ibdata1
170421 18:34:56 >> log scanned up to (201239294)
170421 18:34:57 >> log scanned up to (201239294)
/backup> innobackupex --defaults-file=/etc/my.cnf --user=root --password='xxxxx' /backup/20170803
170421 18:15:39 innobackupex: Starting the backup operation
IMPORTANT: Please check that the backup run completes successfully.
At the end of a successful backup run innobackupex
prints "completed OK!".
170421 18:15:39 version_check Connecting to MySQL server with DSN 'dbi:mysql:;mysql_read_default_group=xtrabackup' as 'root' (using password: YES).
170421 18:15:39 version_check Connected to MySQL server
170421 18:15:39 version_check Executing a version check against the server...
170421 18:15:39 version_check Done.
170421 18:15:39 Connecting to MySQL server host: localhost, user: root, password: set, port: 0, socket: (null)
Failed to connect to MySQL server: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2).
仔细检查,发现输入的用户名和密码都是正确的,而且可以正常连接到数据库
/backup/MySQL_Backup/bin> mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 12
Server version: 5.6.21-70.1-log Percona Server (GPL), Release 70.1, Revision 698
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
报错原因:
在配置文件中没有配置socket
Xtrabackup在备份时,会使用本地的socket连接到数据库
解决方法:
在配置文件中增加socket选项
[root@localhost bin]# cat /etc/my.cnf
[mysqld]
basedir = /usr
datadir = /var/lib/mysql
log-error = /var/lib/mysql/localhost.localdomain.err
pid-file = /var/lib/mysql/localhost.localdomain.pid
#port = 3306
socket = /var/lib/mysql/mysql.sock
之后重启数据库,可以正常备份
/backup> innobackupex --defaults-file=/etc/my.cnf --user=backup --password='backup' /backup/20170803
170421 18:34:54 innobackupex: Starting the backup operation
IMPORTANT: Please check that the backup run completes successfully.
At the end of a successful backup run innobackupex
prints "completed OK!".
170421 18:34:54 version_check Connecting to MySQL server with DSN 'dbi:mysql:;mysql_read_default_group=xtrabackup;mysql_socket=/var/lib/mysql/mysql.sock' as 'backup' (using password: YES).
170421 18:34:54 version_check Connected to MySQL server
170421 18:34:54 version_check Executing a version check against the server...
170421 18:34:54 version_check Done.
170421 18:34:54 Connecting to MySQL server host: localhost, user: backup, password: set, port: 0, socket: /var/lib/mysql/mysql.sock
Using server version 5.6.21-70.1-log
innobackupex version 2.4.4 based on MySQL server 5.7.13 Linux (x86_64) (revision id: df58cf2)
xtrabackup: uses posix_fadvise().
xtrabackup: cd to /var/lib/mysql
xtrabackup: open files limit requested 0, set to 32768
xtrabackup: using the following InnoDB configuration:
xtrabackup: innodb_data_home_dir = .
xtrabackup: innodb_data_file_path = ibdata1:12M:autoextend
xtrabackup: innodb_log_group_home_dir = ./
xtrabackup: innodb_log_files_in_group = 2
xtrabackup: innodb_log_file_size = 50331648
InnoDB: Number of pools: 1
170421 18:34:54 >> log scanned up to (201239294)
xtrabackup: Generating a list of tablespaces
InnoDB: Allocated tablespace ID 45 for dmcdbTEST/com_numbering_plan, old maximum was 0
170421 18:34:55 >> log scanned up to (201239294)
170421 18:34:55 [01] Copying ./ibdata1 to /backup/20170803/2017-04-21_18-34-54/ibdata1
170421 18:34:56 >> log scanned up to (201239294)
170421 18:34:57 >> log scanned up to (201239294)
备份
数据
数据库
配置
文件
原因
密码
方法
用户
用户名
检查
输入
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
中关村互联网科技集团
美国互联网保险保险科技
金融科技还是互联网
互联网科技垄断
美国互联网科技巨头监管
互联网科技的发展
互联网金融公司科技
互联网 的科技创新
朗涯互联网科技
互联网高科技企业
汉立互联网科技有限公司联系电话
哈尔滨新华互联网科技学院
科技与互联网哪个更好
互联网保险科技创业
本届互联网博览会上的黑科技
徐州市互联网科技有限公司
恒生互联网科技业指数调整周期
雨阳互联网卡科技有限公司
富国互联网金融科技混合基金
河南商务圈互联网科技有限公司
齐家互联网科技
紫鲸互联网科技
丰台科技园 互联网
卓越科技互联网 招聘
互联网科技实习生岗位职责
科技类公司包括互联网吗
长沙茂晟互联网科技有限公司
锡山区互联网智能科技产品供应
35岁以上互联网科技行业
互联网科技企业商标注意事项