Friday, February 01, 2008

MySQL : grant command

The GRANT function is used both to create new users, and to assign privileges to users.
mysql>GRANT SELECT, INSERT, UPDATE, DELETE
->ON widgets.* TO widgetAdmin@localhost
->IDENTIFIED BY 'ilovewidgets';

Assuming that the user widgetAdmin did not yet exist when this query is executed, both the user and db tables will be updated with the necessary rows.

The above is taken from dev.mysql.com.

You can also use assign all privileges to a user on a certain database. Following is the syntax.

mysql> GRANT ALL PRIVILEGES ON
    -> test.* TO 'ketan'@'localhost'
    -> IDENTIFIED BY 'ketans_password';

I find this command exceedingly useful ! A quick way to set up privileges of a user on a db.

3 comments:

Christoff said...

Hi there,

I came across your site vir linkreferral and thought it was a really great site! Loved snooping around a bit!

Keep it up.

Regards,
Christoff Gouws
ZAVibes.com

Ketan said...

Thanks Christoff !

Keep visiting my blog. I plan to become active now here :-).

Ketan

Anonymous said...
This post has been removed by a blog administrator.