When a new user is added to a virtual server with a database access, the user/password doesnt work in mysql. This happens if the username format is set to user.domain in server templates.
I changed the username format to user@domain and it only works if we choose a username that makes username@domain less than 16 characters. in fact the username is truncated by mysql (for mysql < 5.7.8)
To fix this bug I think it's better to move the database user creation from Edit users to Edit databases page so that users can manage their database users there where virtualmin takes account of database username limitations