Since I started installing ERPNext onto Ubuntu 20.04 I’ve never been able to use root as the mariadb user.
For some reason sudo is required. Even if you try mysql -u root -p then your password you will likley get an access denied error.
To solve this create new user will all permissions and grant option. Ex.
CREATE USER erpnext@localhost IDENTIFIED BY 'ABCD1234';
GRANT ALL PRIVILEGES ON mydatabase.* TO erpnext@localhost WITH GRANT OPTION;
Then you can run your restore command
bench --site {site} restore {path/to/database/file} --with-public-files {path/to/public/archive} --with-private-files {path/to/private/archive} --mariadb-root-username erpnext --mariadb-root-password ABCD1234