I have four questions in one.

*_FIRST_QUESTION:_*

Via a perl script, have I added a user(actually two, with the same
name, just attached to different addresses). Below here you can se my
code:


Code:
--------------------
$con->query("CREATE USER '".$NEWADMIN."'\@'".$server."' IDENTIFIED BY '".$DBADMINPASS."';");
$con->query("GRANT SELECT,INSERT,UPDATE,DELETE ON ".$dbname.".* TO '".$NEWADMIN."'\@'".$server."';");
$con->query("GRANT SELECT,INSERT,UPDATE,DELETE ON ".$dbname.".* TO '".$NEWADMIN."'\@'%';");
--------------------



Now. Another part of my code is building the username from an E-Mail
replacing both @ and dot to underscore(name_domain_tld(.com etc)). But
this code didnt work(unfortunately). So now I have two users with
usernames xx@xxx.xx. They are created but havent got any privileges to
any db because when I try to do:


Code:
--------------------
REVOKE ALL PRIVILEGES ON *.* FROM 'xx@xxx.xx';
--------------------


it says query ok, 0 rows affected.
I then trys to drop user, but I cant.
Can u help me?


_SECOND_QUESTION:__

The scenario is like this:

The customer will be using the MySQL database with homepages as they
will be both ISP and Webhotel providers. So when a new customer is
created in eDir, IDM will automatically invoke the add script that will
add a new domain and database. On the database server it meens that one
database with the name of the domain but with underscore instead of dot
will be created. Next a new Database administrator will be created with
the code as shown above in question number one.
So actually my real need is to be verifyed that the code is correct.


_THIRD_QUESTION:__

When there is just the smallest modification on anything that have
influende on MySQL(new db admin, etc except password.), a modify command
will be sent to the mysql server and a modify script will be invoked(you
all know this). Now. I cant just ask for the paramters been modified
only, so I have to update all the information in one time. That
unfortunately meens that I have to remove the old admin and create him
again with his privileges. Another action COULD be to disable access to
the database(revoke the privileges for the db admin, but not drop him).
So I have made a code looking like this:



Code:
--------------------
my $con = Mysql->connect($host, "mysql", $admin, $adminpass);

if($DISABLED eq "true")
{
my $query = $con->query("SELECT User FROM db WHERE Db = '".$dbname."';");
while(my %hash = $query->fetchhash)
{
my $user = $hash{0};
$con->query("REVOKE ALL PRIVILEGES ON ".$dbname.".* FROM '".$OLDADMIN."'\@'%';'");
$con->query("REVOKE ALL PRIVILEGES ON ".$dbname.".* FROM '".$OLDADMIN."'\@'".$server."';'");
$con->query("FLUSH PRIVILEGES;");
}
}
else
{
my $query2 = $con->query("SELECT User FROM db WHERE Db = '".$dbname."'");
while(my %hash = $query2->fetchhash)
{
my $user = $hash{0};
$con->query("DROP USER ".$user.";");
$con->query("FLUSH PRIVILEGES;");
}
$con->query("CREATE USER '".$NEWADMIN."'\@'".$server."' IDENTIFIED BY '".$DBADMINPASS."';");
$con->query("GRANT SELECT,INSERT,UPDATE,DELETE ON ".$dbname.".* TO '".$NEWADMIN."'\@'".$server."';");
$con->query("GRANT SELECT,INSERT,UPDATE,DELETE ON ".$dbname.".* TO '".$NEWADMIN."'\@'%';");
}
--------------------


Now. This code doesnt seem to work 100%.
When I do a migrate, it does create an admin.
Can you verify for me that I am doing this right? Or even if I am
thinking right but doing wrong?


*_FOURTH_QUESTION:_*

Deletion of a database(inclusive the admin).
A simple question so i just post the code right away:



Code:
--------------------
my $con = Mysql->connect($host, "mysql", $admin, $adminpass);
my $query = $con->query("SELECT User FROM Db WHERE Db = '".$dbname."';");
while(my %hash = $query->fetchhash)
{
my $user = $hash{0};
$con->query("REVOKE ALL PRIVILEGES ON ".$dbname.".* FROM '".$user."'\@'%';");
$con->query("REVOKE ALL PRIVILEGES ON ".$dbname.".* FROM '".$user."'\@'".$server."';");
$con->query("FLUSH PRIVILEGES;");
$con->query("DROP USER ".$user.";");
}
--------------------


Again, can you verify for me that this SHOULD work?


--
kkrasmussen
------------------------------------------------------------------------
kkrasmussen's Profile: http://forums.novell.com/member.php?userid=20966
View this thread: http://forums.novell.com/showthread.php?t=349814