Error: SQL grant all on `database`.* to 'databaseuser'@'localhost' with grant option failed : You are not allowed to create a user with GRANT

Operating system: Ubuntu
OS version: 20.04 LTS latest with MySQL 8.0.25

When transfering a site with an additional user having access to MySQL 5.7.33 on Ubuntu 16.04, onto a new server with Ubuntu 20.04 with MySQL 8.0.25, I get following error:

  Re-creating mail and FTP users ..
Error: SQL grant all on `database`.* to 'databaseuser'@'localhost' with grant option failed : You are not allowed to create a user with GRANT
Error
-----
SQL grant all on `database`.* to 'databaseuser'@'localhost' with grant option failed : You are not allowed to create a user with GRANT
-----

It looks like the query used by Virtualmin to restore the additional user is not sufficient for MySQL 8.0.25:

Looks like before granting the user should be created with CREATE USER 'databaseuser'@'localhost' IDENTIFIED BY 'password';, which Virtualmin seems to not be doing for Mysql 8 ?

Found this thread with a similar problem that got solved by switching to MariaDB…: Virtualmin Restore Domain: error while Re-creating mail and FTP users

but as the thread is closed, opening this new one to report the issue.

Also, the Database permissions restored at destination server during the transfer have a backslash before the underscore in the database name, like this vhost\_dbname. Edited them and removed the unneeded .