MySQL modify access privileges or create new users

I am attempting to create script installation Wizard, that would guide administrator through installation steps and as one of the steps  configures new MySQL database to be used by the script.
I have no problem in creating a new database, however it is created without any access rights for any user, including root.
I need to modify access privileges for the configured user to allow this new database access from the Web host, where the Wizard was executed.

This is equivalent to  MySQL command:
GRANT ALL ON dbname.* TO root@'webserver' IDENTIFIED BY 'password' WITH GRANT OPTION;      

What DBI or DBD::MySQL command should I use for this?

Thank You.
LVL 6
sstoukAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ozoCommented:
$dbh->query(qq(GRANT ALL ON dbname.* TO root@'webserver' IDENTIFIED BY 'password' WITH GRANT OPTION));
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ozoCommented:
#sorry, that's for Net::MySQL, for DBD::mysql it looks like you'd want
$dbh->do(qq(GRANT ALL ON dbname.* TO root@'webserver' IDENTIFIED BY 'password' WITH GRANT OPTION));
0
sstoukAuthor Commented:
Wait...
$dbh is generally an example of a database handle.
Do you mean a Driver Handle ($drh) and not a Database Handle ($dbh) ?
I realize that it is just a variable but it makes things clear....
$drh = DBI->install_driver("mysql");
$drh->query(qq(GRANT ALL ON dbname.* TO root@'webserver' IDENTIFIED BY 'password' WITH GRANT OPTION));

???
0
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

sstoukAuthor Commented:
Or the second query ...

$drh = DBI->install_driver("mysql");
$drh->do(qq(GRANT ALL ON dbname.* TO root@'webserver' IDENTIFIED BY 'password' WITH GRANT OPTION));

???
0
sstoukAuthor Commented:
#################################
$drh = DBI->install_driver("mysql");
my($Command) = "GRANT ALL ON $main::Config{CPADbDatabaseName}.* TO $main::Config{CPADbUser}@\'*\' IDENTIFIED BY \'$main::Config{CPADbPassword}\' WITH GRANT OPTION";
$drh->query($Command);
#################################
RESULT:
Can't locate object method "query" via package "DBI::dr" (perhaps you forgot to load "DBI::dr"?)


#################################
$drh = DBI->install_driver("mysql");
my($Command) = "GRANT ALL ON $main::Config{CPADbDatabaseName}.* TO $main::Config{CPADbUser}@\'*\' IDENTIFIED BY \'$main::Config{CPADbPassword}\' WITH GRANT OPTION";
$drh->do($Command);
#################################
RESULT:
Can't locate object method "do" via package "DBI::dr" (perhaps you forgot to load "DBI::dr"?)

Perhaps I should connect a Database Handle to mysql Table?
Shouldn't all the schema be located there and it might be as simple as adding a row to the configuration mysql database?

0
sstoukAuthor Commented:

I think I did this a few years ago already and you are correct.

I have to create a $dbh Database Handle to "mysql" Database and manipulate the values in tables_priv Table by modifying Rights for Specific User.

Git the idea.
thank You.
0
sstoukAuthor Commented:
Yes.
It works well now.
Thank Again.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Perl

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.