Thursday, April 4, 2019

innobackupex cannot connect to localhost but can connect to 127.0.0.1

Problem:

[root@myserver# innobackupex --defaults-file=./temp.cnf --stream=tar /mysql-backup/ |
>     split -d --bytes=1073741824 - /mysql-backup/mysql.backup.test.tar
190327 15:58:01 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!".

190327 15:58:01  version_check Connecting to MySQL server with DSN 'dbi:mysql:;mysql_read_default_group=xtrabackup;mysql_socket=/mysql/data/mysqld.sock' as 'root'  (using password: YES).
190327 15:58:01  version_check Connected to MySQL server
190327 15:58:01  version_check Executing a version check against the server...
190327 15:58:01  version_check Done.
190327 15:58:01 Connecting to MySQL server host: localhost, user: root, password: set, port: not set, socket: /mysql/data/mysqld.sock
Failed to connect to MySQL server: Access denied for user 'root'@'localhost' (using password: YES).

Solution:

The solution to this annoying error is to tell innobackupex to connect to host 127.0.0.1 instead of localhost. You can either had "--host=127.0.0.1" to the command or add it into the defaults-file as "host=127.0.0.1".