SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict greg76's Avatar
    Join Date
    Aug 2004
    Location
    Poland
    Posts
    262
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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


    Best,
    Greg

  2. #2
    Utopia, Inc. silver trophy
    ScallioXTX's Avatar
    Join Date
    Aug 2008
    Location
    The Netherlands
    Posts
    9,032
    Mentioned
    152 Post(s)
    Tagged
    2 Thread(s)
    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 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.
    Rémon - Hosting Advisor

    Minimal Bookmarks Tree
    My Google Chrome extension: browsing bookmarks made easy

  3. #3
    SitePoint Addict greg76's Avatar
    Join Date
    Aug 2004
    Location
    Poland
    Posts
    262
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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
    I will need to look through the WP to see how they do that.


    Thanks again for your time!
    Cheers,
    Greg


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •