0

I have automysqlbackup installed on debian. I added USERNAME and PASSWORD to /etc/default/automysqlbackup, but when automysqlbackup runs, I get the output:

/etc/cron.daily/automysqlbackup:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO

as if I would not have configured any credentials.

The automysqlbackup config is the default configuration with two lines added at the end:

USERNAME=root
PASSWORD="the root password"

The default config tries to get the credentials from /etc/mysql/debian.cnf (using grep in the /etc/default/automysqlbackup bash snippet) which contains a warning that the file is deprecated and does not contain any admin password anymore on new installations.

I tried automysqlbackup with strace and it at least reads /etc/default/automysqlbackup even when not started by cron. It doesn't use the password, though.

allo
  • 1,620
  • 2
  • 22
  • 39
  • Can you show us your config? – vidarlo Feb 12 '23 at 12:23
  • 1
    @vidarlo I added it to the question, but I only changed USERNAME and PASSWORD, as it tries by default to get it from `debian.cnf` which is deprecated and does not contain a password anymore. – allo Feb 12 '23 at 12:26

1 Answers1

0

The problem was to append the USERNAME and PASSWORD at the end of the file, while the file is evaluated as shellscript and contains some mysql commands to list database names that already require a login.

It also seems to make strong assumentions that debian.cnf is available and contains the needed credentials, by finding databases like this:

DBNAMES=`mysql --defaults-file=/etc/mysql/debian.cnf --execute="SHOW DATABASES" | awk '{print $1}' | grep -v ^Database$ | grep -v ^mysql$ | grep -v ^performance_schema$ | grep -v ^information_schema$ | tr \\\r\\\n ,\ `

which would probably need parameters to use $USERNAME and $PASSWORD instead of the deprecated defaults file.

I know that old mysql/mariadb packages configured a maintenance user in debian.cnf but a fresh install does not contain such a account and so the script already fails when trying to list the databases.

The configuration file already contains a commented out alternative that seems to work:

DBNAMES=`find /var/lib/mysql -mindepth 1 -maxdepth 1 -type d | cut -d'/' -f5 | grep -v ^mysql\$ | tr \\\r\\\n ,\ `

I must say, that both lines look a bit fragile to me. I am not sure if this won't break sometime and if the whole automysqlbackup script or at least its configuration may not be the most robust solution.

allo
  • 1,620
  • 2
  • 22
  • 39