Under the latest myslq/mariadb they changed the authentication scheme so that connections to mysql from localhost root user don’t need authentication. This is not the case for non-root. For example on FreePBX 17
tedm@phony:/$ whoami
tedm
tedm@phony:/$ su
Password:
root@phony:/# mysql
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 18182
Server version: 10.11.6-MariaDB-0+deb12u1 Debian 12
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> exit
Bye
root@phony:/#
However FreePBX also changed it to assign a random password to the userID it uses, thus:
root@phony:/# sudo -u asterisk -s
asterisk@phony:/$ grep PASS /etc/freepbx.conf
$amp_conf["AMPDBPASS"] = "YB3k9ZgcJx41";
asterisk@phony:/$
asterisk@phony:/$ mysql -ufreepbxuser -pYB3k9ZgcJx41
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 18200
Server version: 10.11.6-MariaDB-0+deb12u1 Debian 12
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> exit
Bye
asterisk@phony:/$
The error message you posted:
Access denied for user ‘dbuser’@‘localhost’
certainly seems to indicate that the variable dbuser does not exist anymore…