Database, user & pass, user privlgs - on the fly - is it possible?

Hey,

a client of mine requested a system that generates new sites (with separate domains, databases) with just one click.

How it works:
Domain is registered and pointed to a specific folder on the company’s server - this one is done manually.
This new website has two DB feeds - one being the company’s main db where all the info about all of other sites is held, like name and address, and the other feed is a local one, only for specific needs of that particular site, and that depends on the nature of the site.

Now my humble person should step in and 1st create a CMS to hold all the sites, those already active and those to-be-activated-soon. No sweat about that.

Point is the client wants me to build a system that not only adds a new row to an already existing database (master db feed) when the form is filled&sent out - she wants me to create a whole follow-up:
So 1. add new row to master database with this new site,
2. create a folder (subfolder) on the server for that new site and copy few files into it,
3. create this local database for every new domain (as localhost) with unique user name and password.

All in ONE click only. #1 and #2 I can more or less easily do.
#3 - this type of things were always done manually via installed control panel.

Now…

Not sure if I made meself clear. The whole idea is kinda blur to me, meself, so I apologize for that lousy description.
If any of you did get what I meant, is it even possible to do with plain PHP?

Like creating whole databases and users and users’ privileges by just executing PHP scripts and not using cPanel, or Plesk or VDesk etc?

Looking forward to hearing from any of you,
and thank you for going through my happy English :slight_smile:

Best,
Greg

Creating databases and assigning privileges etc can be done through queries, and since PHP can talk to MySQL, you can indeed create databases with PHP and assign users to them.

Take a look at CREATE DATABASE and [URL=“http://dev.mysql.com/doc/refman/5.6/en/grant.html”]GRANT.

Note that you need enough privileges to create databases and to GRANT. Only users created WITH GRANT OPTION can grant privileges to others, and they can only grant privileges that they have themselves. Out of the box only the root user has this privilege IIRC, so you’d probably want to create an extra user to create the databases.

Howdy ScalioXTX, thanks for your reply.

What the client really wants is, with just one click, creating the whole database, its user and password plus few base tables.

Actually, Wordpress does similar thing, so I guess I answered my own question :slight_smile:
I will need to look through the WP to see how they do that.

Thanks again for your time!
Cheers,
Greg