Creating MySQL Databases

Peter Reid preid at reidit.co.uk
Mon Mar 21 03:35:40 EST 2005


>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
>
><snip>
>
>Here's what I do (extract) to create MySQL databases from within
>runrev. Send the commands to a text file, then execute the MySQL
>client using the text file as a command script:
>
>  <snip>
>
>--
>-Mark Wieder
>  mwieder at ahsoftware.net

Hi Sarah & Mark

Thank you both for your code fragments which are very helpful. 
However, the problem I have is how to address the MySQL server on a 
different system, not the one the Rev program is running on.

If my Rev program were running on the same system as the MySQL server 
then I might send "mysql < createDB.sql" as a shell command. 
However, the "mysql" command only exists on a different system on my 
local network (IP 192.168.0.99, say) whilst I'm running the Rev 
program on my local system (IP 192.168.0.3, say). So the problem is 
that "mysql" is actually "/usr/local/mysql/bin/mysql" on 192.168.0.99 
whilst "createDB.sql" is actually "/Users/fred/Documents/creatdb.sql" 
on 192.168.0.3.  How do I construct the shell command in this 
situation?

Just a thought here, but if my Rev program is actually on the server 
system (in "/User/dbuser/Documents/" say) and the user executes it 
directly from there whilst remote-connected to the system as 
"dbuser", will this all work as if the MySQL server and the rev 
program were all running locally?  (My understanding is that if you 
execute a program on a remote system, then it's actually running in 
the memory of your system, not the remote one??).

By the way, all this cross-system addressing messiness is hidden for 
the SQL commands that Rev supports, which is why it would have been 
nice if it supported database creation and status listing (so you can 
list existing databases, etc.).  The main reason I'm using MySQL is 
for a client-server application, which is why this sort of detail 
would be better encapsulated within the Rev SQL database support!

Cheers
Peter
-- 
Peter Reid
Reid-IT Limited, Loughborough, Leics., UK
E-mail: preid at reidit.co.uk


More information about the use-livecode mailing list