Score:0

Automysqlbackup does not use the configured password

in flag

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.

vidarlo avatar
ar flag
Can you show us your config?
in flag
@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.
Score:0
in flag

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.

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.