Cron job for mysql access denied

SYSTEM INFORMATION
OS type and version LInux 18.04.6
Webmin version 2.105

I have a shell script that I want to use to backup my mysql folder using xtrabackup that runs perfectly from the cmd line using sudo.
When I try and run this from WEBMIN as a cron job using same user name and password I get the following error
I have studied some of the similar problems and solutions posted but none seemed to solev my problem — need some help please.

Backing up database please wait until backup is complete
240128 12:54:18 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.
240128 12:54:18 Connecting to MySQL server host: localhost, user: not set, password: not set, port: not set, socket: not set
Failed to connect to MySQL server: Access denied for user ‘root’@‘localhost’ (using password: NO).
mysql backup encountered a problem look in database.err for information.

All my other cron jobs - not mysql related - run ok

I think you need a password to connect to MariaDB/MySql.

Why bother with a Cron when you can set backup schedules in Webmin/Virtualmin?

you say

using same user name and password

but the error refers to the ‘root’ user – why is that – could that be the issue here – sorry I don’t know how to fix this.