文章详情

短信预约-IT技能 免费直播动态提醒

请输入下面的图形验证码

提交验证

短信预约提醒成功

Xtrabackup备份报错Failed to connect to MySQL server

2024-04-02 19:55

关注
Xtrabackup备份报错
/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)
阅读原文内容投诉

免责声明:

① 本站未注明“稿件来源”的信息均来自网络整理。其文字、图片和音视频稿件的所属权归原作者所有。本站收集整理出于非商业性的教育和科研之目的,并不意味着本站赞同其观点或证实其内容的真实性。仅作为临时的测试数据,供内部测试之用。本站并未授权任何人以任何方式主动获取本站任何信息。

② 本站未注明“稿件来源”的临时测试数据将在测试完成后最终做删除处理。有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341

软考中级精品资料免费领

  • 历年真题答案解析
  • 备考技巧名师总结
  • 高频考点精准押题
  • 2024年上半年信息系统项目管理师第二批次真题及答案解析(完整版)

    难度     813人已做
    查看
  • 【考后总结】2024年5月26日信息系统项目管理师第2批次考情分析

    难度     354人已做
    查看
  • 【考后总结】2024年5月25日信息系统项目管理师第1批次考情分析

    难度     318人已做
    查看
  • 2024年上半年软考高项第一、二批次真题考点汇总(完整版)

    难度     435人已做
    查看
  • 2024年上半年系统架构设计师考试综合知识真题

    难度     224人已做
    查看

相关文章

发现更多好内容

猜你喜欢

AI推送时光机
位置:首页-资讯-数据库
咦!没有更多了?去看看其它编程学习网 内容吧
首页课程
资料下载
问答资讯