MySQL Forums
Forum List  »  Perl

Privilege granting problem
Posted by: Markus Thueringer
Date: April 14, 2006 07:07AM

Hi!
I am trying to grant all privileges on a newly created database
to an user via a perl-script. Creating the databse and communicating with it works fine, but granting the privileges on the user always fails.There is no error message. The syntax seems right, as mysql seems to accept it.
But the line doesn't seem to have an effect.
What could the problem be?
Thanks in advance to any help on it

#! /usr/bin/perl
use DBI;


&mysql("sigmund","pass");

sub mysql
{
open(FH1,"|mysqladmin -u root --password='pass' create $_[0]");
close(FH1);
print "$? \n";

$dbh = DBI->connect("DBI:mysql:$_[0]:localhost","root","pass");
print STDERR "Error connecting to $_[0]: $DBI::errstr\n" unless $dbh;

# Here seems to be the problem
$sth = $dbh->do("grant all privileges on $_[0].* to $_[0]@localhost identified by '$_[1]' with grant option");

$dbh->disconnect();

open(FH3,"|mysql -u $_[0] --password='$_[1]' $_[0]");
close(FH3);
print "$? \n";

}

Options: ReplyQuote


Subject
Written By
Posted
Privilege granting problem
April 14, 2006 07:07AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.