开发者社区> 潇湘隐者> 正文
阿里云
为了无法计算的价值
打开APP
阿里云APP内打开

XtraBackup出现 Can't connect to local MySQL server through socket '/tmp/mysql.sock'

简介:
+关注继续查看

Xtrabackup做备份时遇到下面错误信息MySQL server: Can't connect to local MySQL server through socket '/tmp/mysql.so‘(2)

 
[root@MySQL-DB ~]# innobackupex --defaults-file=/usr/my.cnf --user=root --password=password  /mnt/resource/mysql_backup
160322 22:28:43 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!".
 
160322 22:28:43  version_check Connecting to MySQL server with DSN 'dbi:mysql:;mysql_read_default_group=xtrabackup' as 'root'  (using password: YES).
Failed to connect to MySQL server as DBD::mysql module is not installed at - line 1327.
160322 22:28:43 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).

clip_image001

 

出现这种情况是因为我修改了my.cnf中参数datadir,但是没有修改socket参数(参数为空),所以出现这个错误。另外我估计更换MySQL数据目录后,如果没有正确配置也会出现这个错误. 我们首先找到对应的mysql.sock文件位置,然后修改my.cnf中的参数scoket值,重启MySQL服务即可解决

[root@MySQL-DB mysql_backup]# find / -name "mysql.sock"
 
/var/lib/mysql/mysql.sock

clip_image002

另外,其实我这篇文章ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)里介绍的建立软连接也可解决这个问题。

另外,在网上也有种偏方解决这个问题,即指定--host=127.0.0.1也可避免这个错误,我测试确实也能解决问题。不过这个是个治标不治本的方法.

innobackupex --defaults-file=/usr/my.cnf --user=root --password=password --host=127.0.0.1 /mnt/resource/mysql_backup

  

版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。

相关文章
Can't connect to local MySQL server through socket '/tmp/mysql.sock'
Can't connect to local MySQL server through socket '/tmp/mysql.sock'
0 0
Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock'
版权声明:本文为 testcs_dn(微wx笑) 原创文章,非商用自由转载-保持署名-注明出处,谢谢。 https://blog.csdn.net/testcs_dn/article/details/51405416 ...
400 0
Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock'
高高兴兴的装完了Mysql,想着执行一下 mysql 测试一下,结果出现以下错误提示:ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.
442 0
Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
<span style="color:#3333ff">[root@t1 /]#  innobackupex --user=root --password=123456 /mydata/data</span><br><br><br> InnoDB Backup Utility v1.5.1-xtrabackup; Copyright 2003, 2009 Innobase Oy<br>
1958 0
connection to dat Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
<p><br></p> <p>[root@t1 ~]# tail /tmp/zabbix_server.log <br><span style="color:#3366ff"> 23392:20160303:131022.598 [Z3001] connection to database 'zabbix' failed: [2002] Can't connect to local My
2956 0
error: 'Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)'
 [root@luozhonghua ~]#   /usr/bin/mysqladmin -u root password 'aaaaaa' /usr/bin/mysqladmin: connect to server at 'localhost' failed error: 'Can't connect to local MySQL server through socket '/v
852 0
+关注
潇湘隐者
网名潇湘隐者/潇湘剑客、英文名Kerry,兴趣广泛,广泛涉猎,个性随意,不善言辞。执意做一名会写代码的DBA,混迹于IT行业
文章
问答
文章排行榜
最热
最新
相关电子书
更多
从花农到MySQL大
立即下载
从华农到MySQL大神
立即下载
MySQL Replication: Latest Developments
立即下载