Monday, April 26, 2010

MySQL: Create user and grant a user

To create a user, do

create user 'myuser' identified by 'iampassword';

To grant a user, do
grant select, alter, alter routine, create, create routine, create temporary tables, create user, create view, delete, drop, execute, file, grant option, index, insert, lock tables, process, references, reload, replication client,replication slave, show databases, show view, update, usage on *.* TO 'ipyrusc'@'localhost';

The strings "select, lock, alter, alter routine, etc..." are privileges that you can select to what privilige you want the user created to have. Note that the 'myuser' is specified when granting the priviliges.

To assure this user exist, you can do query by
select user,host from mysql.user;
to show the users of MySQL.

To know more about this, check the page about granting and adding a user at MySQL website.

No comments: