List:General Discussion« Previous MessageNext Message »
From:Martin Ramsch Date:September 8 1999 6:47pm
Subject:Re: How do you grant privileges to create dbs but not touch other dbs ?
View as plain text  
On Wed, 1999-09-08 13:02:07 -0400, John Millaway wrote:
> I would like certain users to be able to create as many databases as
> they want, and access them freely (essentially full-control without
> admin privileges)... but they aren't allowed to access each others'
> databases or the main database. How is this accomplished?

This can be done, if you put wildcars into the field mysql.db.db.

Here's an example with a new user:

  GRANT ALL PRIVILEGES ON dummy.* TO joe@% IDENTIFIED BY 'passwd';
     /* this creates the new user 'joe' with password 'passwd',
        who may connect to MySQL from any host (%) and has all
        priviledges on the database 'dummy' */
  UPDATE mysql.db SET db='joe_%' WHERE user='joe' AND db'=dummy';
     /* This does the trick to put a database pattern into the
        db table.  GRANT unfortunately doesn't accept any syntax
        with such wildcards. */
  FLUSH PIVILEGES;
     /* Without this MySQL wouldn't notice our manual changes
        done with UPDATE instead of GRANT */

Now user 'joe' can create and drop any database that has a name
starting with 'joe_'.  But as he has no rights on other databases, so
he can't do any harm elsewhere.


Regards,
  Martin
-- 
Martin Ramsch <m.ramsch@stripped> <URL: http://home.pages.de/~ramsch/ >
PGP KeyID=0xE8EF4F75 FiPr=52 44 5E F3 B0 B1 38 26  E4 EC 80 58 7B 31 3A D7
Thread
How do you grant privileges to create dbs but not touch other dbs?John Millaway8 Sep
  • Re: How do you grant privileges to create dbs but not touch other dbs ?Martin Ramsch8 Sep