View Full Version : Create MYSQL database with MivaScript?
wmgilligan
05-26-08, 06:31 AM
Can MivaScript be used to actually create a MySQL database, or does one have to already exist (ie - create in phpmyadmin)?
Bill
mvmarkus
05-26-08, 10:29 AM
Can MivaScript be used to actually create a MySQL database, or does one have to already exist (ie - create in phpmyadmin)?
Bill
Hi Bill,
Yes. You connect to another (existing) MySQL table (for example the mysql or information_schema in v5.++) and run MvQUERY or MvDBCOMMAND with the CREATE DATABASE statement from there.
Markus
dotCOM_host
05-26-08, 08:58 PM
One caveat: Many web control panels (Plesk, Ensim, cPanel, etc) require that you create the database through the control panel itself, first. This way the database gets assigned properly to the client account - so it counts towards their quotas, is backed up along with the rest of their domain, and so on. By default these control panels also do not grant the "CREATE" permission in mySQL for the user you may be using to create a new database - which will force you to have to create the database through the control panel anyway.
If you are building something that needs to be universal and working across a number of servers, where you don't know whether the server has one of these control panels, or whether the mySQL account has permissions to use CREATE statements, I'd recommend documenting this and requiring that the client creates the database first, using whatever methods the host provides or are supported by their system. You can't assume that if your local dev system has full rights to mySQL that you will have the same permissions on a shared web server...
vBulletin® v3.7.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.