Creating MySQL Databases

Sarah Reichelt sarahr at genesearch.com.au
Sun Mar 20 20:54:31 EST 2005


> I'm just starting a project using MySQL for the first time.  Having 
> looked at the Rev 2.5.1 documentation, I'm happy enough that I can 
> access and update MySQL databases as required.  However, what I can't 
> see is how I can create and carry out basic administration of NEW 
> databases.
>
Hi Peter,

Here is my script for creating a new database. It connects directly to 
the "myslq" database as root (or any user that has the right 
privileges) and sends the create database command to that. I have only 
done it on a local database, so you will need to change the value for 
dbAddr.

I don't know how to rename a database, but if you can find the SQL 
command to do it, then I would hope that this technique would work for 
that as well.

Cheers,
Sarah


on mouseUp
   put "root" into dbUser
   put "mysql" into dbName
   put "localhost" into dbAddr

   ask password clear "Enter root password:"
   if the result = "Cancel" then exit to top
   put it into dbPass

   put revOpenDatabase("MySQL",dbAddr,dbName,dbUser,dbPass) into dbresult
   if dbResult is not a number then
     answer error dbResult as sheet
     exit to top
   end if
   put dbResult into dbID

    ask "Enter the name of the new database:"
   if the result = "Cancel" then exit to top
   put it into newDB
   put "CREATE DATABASE " & newDB into dbSQL

   revExecuteSQL dbID, dbSQL
   put the result into sqlResult

   if sqlResult is a number then
     answer information "Database " & newDB & " created." as sheet
   else
     answer error sqlResult as sheet
   end if

   revCloseDatabase dbID
end mouseUp



More information about the use-livecode mailing list