I get access denied for username@localhost when running archive. The database is on a different server which is specified in the host field of the config.ini.php file.
[database]
host = host.domain.com or IP address
username = matomo_dbadmin
password = @@@@@@@
dbname = Matomo_Analytics_prod
tables_prefix = Matomo_
port = 3306
adapter = PDO\MYSQL
type = InnoDB
schema = Mysql
If the rest of Matomo is working fine, then your MySQL user is most likely missing the permission to create temporary tables. A proper error message is coming with Matomo 4: