[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [cobalt-users] Help Needed: High Level Overview of PHP and MySQL on Raq4i



le 1.10.2001 6:57, Rusty Wilson à rustyw007@xxxxxxxxx a écrit :

> Hi all,
> 
> I searched through the archives, but was not able to
> find an answer to the question I have. Any input would
> be greatly appreciated.
> 
> QUESTION:
> What is the procedure/process for allowing users of a
> RaQ 4i to create php apps that use MySQL?
> 
> I am NOT looking for step by step instructions, but I
> am somewhat confused as to how it all "fits together".
> 
> BACKGROUND:
> I understand PHP and MySQL, and I have used them to
> build apps, *BUT* I have always had administrative
> access to the box I was running PHP and MySQL on.
> 
> The confusion I have is how to extend this
> functionality to clients I host on some of my Raq 4i
> servers? Since they dont have admin (or even shell
> access), how do they create the mysql database that
> their php app will supposedly use?
> 
> Any one already doing this for their clients, and have
> a general process they are willing to share with me?
> 
> Thanks in advance!
> Rusty
> 
> 
I use an extremely simple PHP page which requires me to enter a database (
"customer_db")  name and a password. This will create a database and user
customer_db which is allowed to access his database from localhost and using
his password.

I'm working on an integrated solution for our GUI, which will include the
automatic creation of a MySQL database and moving it into the clients
directory so that the quota given to our customer will include their
database. More news on this one later.

Another solution would be to create a little perl script, like this one
(put it into your admin folder, so that you can easily access it ,via
SSH/Telnet ). 

if ($#ARGV!=1) {
  print "Syntax : newmysql <dbname> <password>\n\n";
}

if ($#ARGV==1) {
  @args = ("mysql", "-e", "create database $ARGV[0]");
  system(@args);

    print "Database created\n";


  @args = ("mysql", "-e", "grant all on $ARGV[0].* to $ARGV[0]@\"localhost\"
identified by '$ARGV[1]'");
  system(@args);

  print "Access granted\n";
  print "Finished\n\n";

}

IN ADDITION, to this you need to create the following file called .my.cnf (
also in your admin folder ) containing this info

[client]
user=root
password=abcdefg


Chmod the perl script 700 and this .my.cnf one 600.

Now you can run the perl script :
./myperlscript mydatabase asjkbdljui

and your database will be created.
However the PHP solution is much easier, because accessible via the web.

Hopes this helps