Failed to create virtual server : mysql user called xxxxxxx already exists

I have an issue where i have two similar names

123456789101112131415.com 123456789101112131415.com.au

the .com already existed. When I try to create the .com.au domain it gives an error saying the mysql user called 1234567891011121 already exists.

I deleted the .com user references and databases.. however I still keep getting this error message..

Status: 
Active

Comments

go into Webmin: Servers: MySQL databases and then remove any traces of the user there. all users are listed under "user permissions".

only do this if the user is truly "orphaned". if it still belongs to a main Webmin account/Virtualmin server, then don't delete it or you will just mess things up further.

Actually the full error is:

Failed to create virtual server : A MySQL login named ???????? is already owned by virtual server ?????????

Substituted the domain name with ???

i know, it's saying this because your new server wants to use a mysql username of "1234" but the user "1234" already exists in the mysql users table and is owned by another server.

if this is intended (the other server should own it), then you can just override the NEW servers mysql username.

in the server creation dialog, set "administration username" to "custom" instead of automatic, and name the user something unique that does not clash with the other existing domain.

ohhh now i re-read your very confusing initial post (those numbers in your domain were hard to read so i didn't bother) and can see the problem!

here is the thing:

let's say i have two websites:

myawesomecoolwebsiteone.com
myawesomecoolwebsitetwo.com

mysql does not support usernames longer than 16 characters, so the first website will get a mysql username that is:

myawesomecoolweb

the second server will try to get the same username.

your solution is to change the administration username for the new site, as I described, to give it a different name.

alternatively, make the new website into a sub-server of the main server, and disable "create mysql database" under sub-server features, that way the new server runs as the old user and can use the same databases etc.

Jamie, do we have a way to handle the case where two domains, each longer than 16 characters, would each produce the same MySQL username?

The only work around is to pick a different username for the second domain on the creation form.

@andrey: nope. there is no case to handle that.

one way to do it is to automatically run a little loop: "name clash? replace last letter with 0. name clash? replace last letter with 1... name clash? replace last letter with 9... name clash? replace last two letters with 10" etc until you find a free name.

so it would try:

mysuperawesomeweb
mysuperawesomewe0
mysuperawesomewe1
...
mysuperawesomew13

etc.

but honestly, the current behavior is pretty nice too. it simply warns you that there is a clash, and the user can use one of my two suggestions (either set an explicitly definied name for the new admin user, or make the new server into a sub-server of the parent server, with "create mysql database" disabled, to share the same database and avoid clashes).

the only thing that's really needed is to make the clash error message more obvious. right now it is a bit vague. would be better if it said "that username is over 16 characters long, and clashes with another domain, so either rename the admin user or make it a sub-server".

I was hoping that there was an option where you could specify the database username in the same way as you can specify the database name. (by default it will use the name as the admin username (with the field limited to 16 characters). The option to have a different database username than admin username at creation would be handy.. Also the option to add prefixes or what not automatically to the template for the database username would be cool as well)..

Sorry about the confusing initial post.. I had spent hours trying to figure out what to do and it was really really tired so just typed the first thing that went to mind before I did a faceplant on the keyboard falling asleep...

Also thanks for your help :)

When creating a new Virtual Server, you can set the admin username (and database name) by setting the "Administration username" field.

Would that do what you're after?

Future wish:*** At the moment it seems that the database username is set to the admin username by the system. Was wondering if you can choose your database UserName that is different than the admin UserName, in a way similar to how you can choose the database Name.

Problem At hand:*** When creating a new domain with a similar existing domain > 16 characters. Failed to create virtual server : A MySQL login named ???????? is already owned by virtual server ?????????

Resolution for the problem at hand: *** Remember I had noted that I had deleted the database name in question and also deleted the database in question.. and was still unable to create the new domain with the exact same error, even after refreshing the system.

What I did to get around the problem at hand: Either way, I was able to get around the issue by making a new domain test.com.au and renaming this domain to the name I wanted. Strangely the renaming process was able to assign the database username that the creation process couldn't...

The creation process seemed to fail because the database username used to exist.. . even after I deleted the original database username and the associated database manually.. By creating a totally different domain, and renaming it to the one I wanted, I was able to bypass the error and it then created the username that the creation process should have been able to do but didn't.

So right now I'm ok. :) Thanks for your help. I know what I just typed seems confusing, but it makes sense to me.

Mostafa's picture
Submitted by Mostafa on Wed, 12/21/2016 - 11:09

This is actually virtualmin bug, here is how to reproduce it: 1- add example.com 2- try adding example.com.au

Virtualmin chooses a username for .com.au domain that already exists on the server!

In this case, is "example" actually a string of more than 16 characters?

Mostafa's picture
Submitted by Mostafa on Thu, 12/29/2016 - 06:00

oh yes it is! so it is actually the max length of mysql dbname that is causing this...

Yes - the work-around is to select a different username on the creation form for the second virtual server.