程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 數據庫知識 >> MYSQL數據庫 >> MySQL綜合教程 >> XtraBackup出現 Cant connect to local MySQL server through socket /tmp/mysql.sock,

XtraBackup出現 Cant connect to local MySQL server through socket /tmp/mysql.sock,

編輯:MySQL綜合教程

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).

 

出現這種情況是因為我修改了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

另外,其實我這篇文章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

 

參考資料:

http://www.cnblogs.com/fuhj02/p/3541173.html

 

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved