Page 1 of 1

how to grants privileges to a user?

Posted: Tue Apr 20, 2004 5:03 pm
by davidklonski
Hello

I am experimenting with creating new users, granting them privileges and revoking them.

Here is what I am trying to do:
create a new user account for a user with username: 'johnsmith' and password: 'johnpassword'.
Allow that user to right to perform the following commands on database 'dbname': select, update, insert

After reading the manual, here is what I tried:
grant select, update, insert on dbname.* to 'johnsmith' identified by password 'johnpassword';

this didn't work because I got an error saying that:
"Password hash should be a 41-digit hexadecimal number"

could someone show me how I can create a new user account and provide that use with the privileges to select, update, insert?

thanks in advance

Posted: Tue Apr 20, 2004 5:12 pm
by tim
/use less

Posted: Tue Apr 20, 2004 5:22 pm
by davidklonski
I am talking about generating MySQL accounts and providing SQL privileges.
I need to know how to do it in DDL of SQL and not in PHP

Posted: Tue Apr 20, 2004 7:54 pm
by Unipus
I believe the password part is not supposed to be there.

grant select, update, insert on dbname.* to 'johnsmith' identified by 'johnpassword';

Posted: Wed Apr 21, 2004 2:45 am
by davidklonski
can you show me the matching revoke command for the same user?
whatever I try, I am getting an error message saying that the SQL statement is invalid

here is correct format, taken from the spec:
REVOKE priv_type [(column_list)] [, priv_type [(column_list)]] ...
ON {tbl_name | * | *.* | db_name.*}
FROM user_name [, user_name] ...

here is what I am trying:
REVOKE select, update, insert ON dbname.* FROM 'johnsmith';

Do I always need to specify the host name as part of the username?
'johnsmith@host'? is 'johnsmith' equivalent to 'johnsmith@localhost' ?

Posted: Wed Apr 21, 2004 6:18 pm
by timvw
davidklonski wrote: Do I always need to specify the host name as part of the username?
'johnsmith@host'? is 'johnsmith' equivalent to 'johnsmith@localhost' ?
Cause i don't like running into trouble, i always use 'user'@'host'