Community Forums
Connect with us on LinkedIn
Community Notice
+ Reply to Thread
Results 1 to 2 of 2
  1. #1
    Member
    Join Date
    Jun 2008
    Posts
    7

    Default postwwwacct - set privleges on new database

    I was able to use the hook script:
    /scripts/postwwwacct
    without a problem.

    In my script I create and populate a couple of databases (via php) with:
    PHP Code:
    shell_exec('mysql < /path/to/mydbs.sql'); 
    However, I need to access the
    mysql.db table
    on localhost to set premissions so the databases will be available for new user. I cannot use
    PHP Code:
    mysql_connect('localhost','root','pass'); 
    The connection fails. I cannot see how to do this via PHP. I am looking at Bash right now. Just rather have it all working in one language.

    NOTE:
    I dont like having my root password in a file like this anyway. So a better solution would be great.

  2. #2
    Member
    Join Date
    Jun 2008
    Posts
    7

    Default Solution using command line

    well, Ive been messing with this for hours when I finally posted, and of course minutes later I got a command line solution.

    user the '-e' parameter
    mysql -e "USE mysql;INSERT INTO db (User,Host,Db,Insert_priv,etc....) VALUES ('newuser','localhost','newuser_basedata','Y',etc....)"
    I should be able to roll that into the php shell_exec() method.

    NOTE:This will work when logged in as root. Look at -u, -p or --user=, --pass= for non root implamentation.

Similar Threads & Tags
Similar threads

  1. Ability to set collation when creating a new database
    By monarobase in forum Feature Requests for cPanel/WHM
    Replies: 2
    Last Post: 09-08-2011, 05:00 PM
  2. Reseller ACL Privleges
    By dwinans in forum New User Questions
    Replies: 2
    Last Post: 06-30-2009, 12:05 PM
  3. How to set up a sql database
    By homaquebec in forum Database Discussions
    Replies: 5
    Last Post: 06-28-2009, 10:28 PM
  4. postwwwacct Add user to MySQL Database
    By cfidecaro in forum cPanel Developers
    Replies: 2
    Last Post: 04-04-2009, 04:32 PM
Linkedin       Facebook       Twitter       RSS       Flickr       YouTube