CLI virtualmin modify-user

While trying to give an existing user access to a newly created database via virtualmin CLI using:

virtualmin modify-user --domain --user existinguser --add-mysql newly_created_dbname

I get this error: A database login with the same name already exists

This command should expect an existing name and give access to the new database.

Title of this post looks incomplete. I do not have permission to change it. If moderator can change it, it would be great.



I wasn't able to re-produce this problem unfortunately.

Does this user already have access to any databases of any type (MySQL or PostgreSQL) ?

Also, does he perhaps have a very long username? MySQL usernames are limited to 16 characters, so it is possible for two different users to have clashing DB logins.

Hi Jamie,

I have a web application that created virtual servers via remote API and was getting this error when using the API. But I noticed that this error happens even if I create this user via UI.

I have done some trial and error to find out why this is happening. I am not sure if I found something. If I create a server and create a user named 'example01' with database access and then recreate the server (delete and create the virtual server again), I will be able to create a user named example01, but I won't be able to give mysql database access to this user as it will give the error "A database login with the same name already exists". So it seems the problem is that virtualmin somehow is not deleting a mysql user created in a virtual server when that server is deleted. In Mysql Server > User Permissions, I can see example01 listed after I delete the virtual server.

I do not know if this is intentional, a new bug or a previously reported bug, but I am still facing this issue with two virtual servers wherein I cannot provide access to database for a user even though there is no user in "Users & Group" which have first 16 characters same.

To recreate this problem at my end, I have to: 1. Create a virtual server and a user in it with database access ( and user example01) 2. Delete the virtual server 3. Create virtual server again and add user example01 4. Try giving example01 access to a database 5. I get error

Vishnu N

I have updated my comment to include steps to recreate this at my end.

How long are your usernames? MySQL unfortunately has a 16 character limit, so two long usernames that have the first 16 chars the same can clash like this.

That is the problem. There are no usernames with first 16 characters same for the users for which I get this error in "Users & Groups" list but I found entry for a deleted virtual server user in Mysql Server > User permissions.

Ah, so that's it - there are leftover MySQL users.

If you create a test domain and then delete it, does a MySQL user get left behind?

Yes. But I do not know where to look for mysql users. The deleted server's mysql user will be listed in webmin > mysql server > user permission page. Is this same as mysql user's? Whichever the case, there is some leftovers related to mysql users which prevents new user with same name to be given mysql database permission.

Yes, the page at Webmin -> Servers -> MySQL Server -> User Permissions lists all users known to MySQL.

So if a user is still there even after you deleted his domain, that's a problem.

Yes, even after deleting virtualserver, I have it's users listed in user permission table.

I haven't been able to re-produce this unfortunately. Is the domain user's mysql username 16 characters long (or longer) ?

Yes, domain user's mysql username is more than 16 characters but after deleting virtual server, it should get deleted. But another important thing that I missed to explicitly mention is that the creation/deletion that I have mentioned above to reproduce this error is via remote API call and not via UI. The immediate difference that I can notice is that the mysql username is not prefixed by linux username when my remote calls create mysql username and creation and deletion are all subservers, not servers. Internally there may be other differences as well.

I will soon send you a list of remote API calls that I make from creation of server till error generation.

Yes, I'd like to see the API commands you used.

For reference, I tried creating and deleting a domain with a long MySQL name with the following commands (run as root from the shell) :

virtualmin create-domain --domain --dir --unix --mysql --pass smeg
virtualmin delete-domain --domain

and the MySQL user was removed OK.

Create subdomain( as a virtual server under an existing server (

Create database(myparentdomain.com4_vishnutestingmsint2_cb79e33_wp) under subdomain

Create user(vishnutestingmsint2_cb79e33) under subdomain: Create name: vishnutestingmsi

Delete subdomain: While the whole sudomain gets deleted along with linux user vishnutestingmsint2_cb79e33, vishnutestingmsi remains in user permissions table in mysql server page

Thanks - this seems like a username length issue.

If you login to the Virtualmin UI after the "create user" step and edit the user vishnutestingmsi , does it show him with access to any MySQL databases?

No, the user vishnutestingmsint2_b6814e5 does not have access to any database after "create-user" is executed but I can see vishnutestin user in mysql user permissions list.

Ok, that looks like part of the problem - if Virtualmin doesn't recognize that the MySQL user is associated with the mail user, it won't be cleaned up.

Does the parent domain perhaps have an admin login that also starts with vishnutestin ?

That was the first thing I checked when this error occurred. I also checked the users and groups in webmin and there are no other user that starts with same characters.

Is there any chance I could login to your system to see what is going wrong here? I'd need root SSH access, and the name of the domain that is seeing the problem from comment #15.

Email me at is this is possible.

I may not have permission to share access to same server but I have another server where i can recreate the problem. I will share that with you. How should I share the access?

Sure, that would work. You could email me the root SSH password for the system, or I can provide you with a root SSH public key.


Sorry for the delay. Still waiting for final approval to share root access. I am told I will get permission in 2 days. Please let me know your email ID. Thank you.

Vishnu N