[SOLVED] Curious database connection refused

Hi, I’m facing a "connection refused error. It was after a database crash, and a (successful) restore from backup (other databases work again on this instance)

It happens always but an occ command helps to debug

sudo -u nextcloud /usr/local/bin/php /usr/local/www/nextcloud/occ trashbin:expire
An unhandled exception has been thrown:
Doctrine\DBAL\Exception: Failed to connect to the database: An exception occurred in the driver: SQLSTATE[HY000] [1044] Access denied for user 'nextcloud'@'localhost' to database 'nextcloud' in /usr/local/www/nextcloud/lib/private/DB/Connection.php:85

Excerpt from config file :

'dbtype' => 'mysql',
'version' => '',
'overwrite.cli.url' => 'https://nextcloud.my.domain',
'dbname' => 'nextcloud',
'dbhost' => 'localhost',
'dbport' => '',
'dbtableprefix' => 'oc_',
'mysql.utf8mb4' => true,
'dbuser' => 'nextcloud',
'dbpassword' => '*****',
'installed' => true,

But, the password is valid ! I can connect to database with mysql CLI to this database.

$ mysql -unextcloud -p
Enter password: (copy/pasted from config file)
Welcome to the MariaDB monitor.

OS : FreeBSD 13
Apache : 2.4.48
PHP-FPM : 7.3.28

What is happening ?
Thanks for helping

Finally solved it.
Seems that the mysql.user table was somehow corrupted :

> DROP DATABASE nextcloud;
> CREATE DATABASE nextcloud;
> USE mysql;
> DROP USER nextcloud@localhost;
> CREATE USER nextcloud@localhost IDENTOIFIED BY '*****'
> GRANT ALL PRIVILEGES ON nextcloud.* TO nextcloud@localhost;
# mysql -p nextcloud < mariadb.nextcloud.dump.sql

And TADAA ! All my files, contacts, events, are present again.
Conclusion : BACKUP, BACKUP again, and BACKUP your backups off-site