Hello,
We have found that the database clash check when creating virtual server do not work properly checking all the databases. Probably It checks only the automatically created databases on virtual server creation. But did not check the additional databases created in them.
How to reproduce:
Create 2 virtual servers: onedomain.com seconddomain.com
then for seconddomain.com in virtualmin go to Edit Databases> create database and fill the name as for example "blog".
now try to create sub-server in onedomain.com with domain blog.onedomain.com. It will fail with the message:
Failed to create virtual server : A MySQL database named blog is already owned by virtual server seconddomain.com
But is should not. It should add
In all other cases we have used the database clash check works and add suffix to the name.
Comments
Submitted by JamieCameron on Fri, 01/23/2015 - 15:17 Comment #1
Virtualmin currently doesn't do any clash prevention for database names - instead, it generally avoids this because the additional databases for other domains is prefixed by the domain name using the default templates.
Submitted by george.asenov on Mon, 01/26/2015 - 04:05 Comment #2
Yes the additional databases should have prefix but they do not have any. If there was prefix this error will not happen.
We have by default in the "default template" > Default database name set to ${PREFIX} but it probably doesn't work.
If there is another setting for this please point it.
Thank you in advance.
Hi,
When I installed Virtualmin I typically set the option "Create database as well as login?" to "No".
This causes Virtualmin to create the credentials in MySQL but NOT create a default database right away.
Instead, when you goto the "Edit Database" screen you can create a database afterward or whenever they are needed as is the case for additional databases.
Give this a try and let us know if you still get the error.
Best Regards,
Peter Knowles
TPN Solutions
Email: pknowles@tpnsolutions.com
Phone: 604-782-9342
Skype: tpnsupport
Website: http://www.tpnsolutions.com
Ask me about my new support plans which include a FREE copy of Virtualmin Pro!!!
Submitted by george.asenov on Tue, 01/27/2015 - 02:47 Comment #4
Hi
tpnsolutions - Yes I know for that solution but it is not solution for us. We need database created when domain is added to the server.
So Jamie is that a bug or some misconfiguration on our side because prefix is not added when additional database is added. I didn't see any prefix added to the databases at all.
The database is added in the way it is wrote in the field when creating database from virtualmin. Also when virtual server is created the database doesn't have prefix. It's name is the same as the username.
The suffix is added when you add sub server and the name of the database name happen to be the same as another database name but only if it is created with another domain. If the name happen to be the same as additional database created it give error that the database name already exists and it is owned by another domain.
Submitted by JamieCameron on Tue, 01/27/2015 - 15:39 Comment #5
It may be that your system isn't configured to add a prefix. This can be set at System Settings -> Server Templates -> Default Settings -> MySQL Database.
Submitted by george.asenov on Wed, 01/28/2015 - 02:01 Comment #6
Hi Jamie,
It is set by default we didn't made any changes there from the default settings.
(I can't attach screenshot "Validation error, please try again. The file you attempted to upload may be too large. If this error persists, please contact the site administrator." the file size is only 111KB .jpg)
Here is a link to the screenshot http://v4.trafficplanethosting.com/bugimg/default_template.jpg
But you probably know the default settings.
Do we need the "Prefix for additional databases" set to something different from the default (which is "none")?
Hi,
The first database never has a prefix. Also, in your screen shot you have "Prefix for additional databases" set to "None" which means they won't get prefixes either.
Out of curiosity, is there a particular reason why you "need" a database created immediately during the Virtual Server creation process?
Disabling the immediate creation of the first database doesn't prevent someone from adding a database, it just would allow the "Prefix" option noted above to be used for database ensuring that no two database names would conflict.
My prefix is usually set to: ${USER}_ which makes all databases (since the initial database is never created in my install) have a name of "username_database", this way both "bob" and "mary" can have a database called "wordpress" as it'd be prefixed with their username like "bob_wordpress" and "mary_wordpress".
Best Regards,
Peter Knowles
TPN Solutions
Email: pknowles@tpnsolutions.com
Phone: 604-782-9342
Skype: tpnsupport
Website: http://www.tpnsolutions.com
Ask me about my new support plans which include a FREE copy of Virtualmin Pro!!!
Submitted by george.asenov on Wed, 01/28/2015 - 06:35 Comment #8
Hi
All the websites on our hosting using databases and adding database for every domain added is easier for the clients.
As I said this is the default configuration. Maybe if this can cause a clash it should be better adding a prefix to be the default setting.
Hi,
Try changing the default database naming schema to use ${USER} vs ${PREFIX}. This would make it use the username of the user which should be unique per user instead of the prefix of the domain.
Best Regards,
Peter Knowles
TPN Solutions
Email: pknowles@tpnsolutions.com
Phone: 604-782-9342
Skype: tpnsupport
Website: http://www.tpnsolutions.com
Ask me about my new support plans which include a FREE copy of Virtualmin Pro!!!