Someone new joined the company and I created an account for her in mysql using the following:
CREATE USER 'username' IDENTIFIED BY 'password'
She needs to create her own schema and so used:
GRANT CREATE ON *.* TO username;
The problem is that now she is able to create new schemas and tables but she cannot do anything with it. I'd like her not to have access to existing schemas/tables but be able to create her own db and do anything with it. Is this possible?
Best Answer
To grant all privs on database
mydb
tousername
To grant privs on a table
mydb.mytable
tousername
I suggest you drop the user first to clear up any server-wide privileges.
Why drop the user first? When you first create a user called
username
and login, username has no privs. Just runSHOW GRANTS;
to see it. It should say something likeGRANT USAGE ON *.* TO username
. At that moment,username
can only login. That's your chance to create privileges.If you run
username will have global database privileges (all databases)
If you run
username will have database-wide privileges on the
mydb
database only.If you run
username will have table privileges on the mydb.mytable only.
You cannot mix them. If you do you accidently slip
username
privileges thatusername
should not have.If you want to see what privileges exist at the three levels run the the following queries
Here are privs for MySQL 5.5
Run the query to see the privs for 5.1 and 5.0