XtraBackup Can't connect to local MySQL server through socket '/tmp/mysql. sock ',
When Xtrabackup is used for backup, the following error message is displayed: 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).
This error occurs because I modified the datadir parameter in my. cnf but did not modify the socket parameter (the parameter is blank. In addition, it is estimated that this error will also occur if the correct configuration is not found after I change the MySQL DATA DIRECTORY. first, find the corresponding mysql. sock file location, and then modify my. the scoket value in cnf can be solved by restarting the MySQL service.
[root@MySQL-DB mysql_backup]# find / -name "mysql.sock"
/var/lib/mysql/mysql.sock
In addition, in this article, ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql. the establishment of soft connections described in sock '(2) can also solve this problem.
In addition, there are some remedies on the Internet to solve this problem, that is, specifying -- host = 127.0.0.1 can also avoid this error, and I can test to solve the problem. However, this is a temporary solution.
innobackupex --defaults-file=/usr/my.cnf --user=root --password=password --host=127.0.0.1 /mnt/resource/mysql_backup
References:
Http://www.cnblogs.com/fuhj02/p/3541173.html