Xtrabackup is now asking for the root password

I’ve run backups several times on our production server with:
xtrabackup --backup --datadir=/var/lib/mysql/ --target-dir=/root/backups

and it worked fine, but now it’s demanding a password:

230316 12:38:49 version_check Connecting to MySQL server with DSN ‘dbi:mysql:;mysql_read_default_group=xtrabackup’ (using password: NO).
Failed to connect to MySQL server: DBI connect(‘;mysql_read_default_group=xtrabackup’,‘’,…) failed: Access denied for user ‘root’@‘localhost’ (using password: NO) at - line 1315.
230316 12:38:49 Connecting to MySQL server host: localhost, user: not set, password: not set, port: not set, socket: not set

I’m certain that the database always had a root password set. How can this have happened ?

George

@graythomp,
PXB will first attempt to read the config file located at ~/.my.cnf Perhaps this file existed in the past with the root password saved, and now the file doesn’t exist, or perhaps the password was removed from this file.

Mystery solved, thanks. Found the file in roots home directory. I run Xtrabackup as root, but my colleague, I believe, runs it using sudo from a different user and he is the one who started having issues. I didn’t know about this file as the system was built by a consulting company.

If your colleague is not running sudo with the correct flags, then root’s home directory won’t be considered/loaded when running xtrabackup.