VirtualMin has its own notion of which databases are being managed by the client. There is a special menu that allows for VirtualMin to pick up heretofore-unmanaged databases:
Edit Databases > Import Database > DBNAME > Import Now
This doesn't actually do any database operations as far as I know. It only exposes a database name to the VirtualMin web interface. Because I have some operations that create databases by script, I'm faced with the issue that I presently have to use the GUI to do the above operation before the user account can see and manage via VirtualMin the databases in question.
What I'm looking for is the Unix (Fedora 10) command line to do the equivalent of the above operation. Something like:
# virtualmin --domain domain.name --name database-name --import
Comments
Submitted by JamieCameron on Sun, 11/01/2009 - 13:21 Comment #1
That's a good suggestion .. I will add an import-database API command in the next release.
You will be able to use it like so :
virtualmin import-database --domain domain.name --type mysql --name database-name
Submitted by Issues on Sun, 11/15/2009 - 17:19 Comment #2
Automatically closed -- issue fixed for 2 weeks with no activity.
Submitted by roopesh on Mon, 11/16/2009 - 19:03 Comment #3
I tried to use this API and had some unexpected behaviors.
MySQL is not enabled on shethpets.com, and default database name already exists (e.g. _).
Expectation: Associate the database with the domain. Enable MySQL with that database name.
# virtualmin import-database --domain shethpets.com --type mysql --name shethpets_mysql_default
The specified database type is not enabled in this virtual server
Associates an existing database with some virtual server.
virtualmin import-database --domain domain.name
--name database-name
--type [mysql|postgres]
Outcome: MySQL not enabled and database not associated with domain.
Attempt 2
I tried to enable MySQL for shethpets.com and figured I would then import the database. Unfortunately it tries to create the database and if the default database name exists, it fails.
Expectation: Enable MySQL, and I will choose which database to associate with the domain, or let me do it at the time of enabling MySQL.
# virtualmin enable-feature --domain shethpets.com --mysqlUpdating server shethpets.com ..
A MySQL database named shethpets_mysql_default already exists
Any thoughts or suggestions?
Thanks!
Submitted by JamieCameron on Mon, 11/16/2009 - 20:08 Comment #4
One work-around would be to temporarily disable the Virtualmin feature that creates a new DB for a domain when the MySQL feature is enabled. You can do this at System Settings -> Server Templates -> Default Settings -> MySQL Database -> Create database as well as login?.
Submitted by roopesh on Thu, 11/26/2009 - 10:36 Comment #5
Is there a way to do that from the command line so that I can put this all in a shell script?
Submitted by JamieCameron on Thu, 11/26/2009 - 13:30 Comment #6
Yes - you can use a command like :
virtualmin modify-template --id 0 --setting mysql_mkdb --value 0