Thursday, November 22, 2007

Create MySQL User

To create a user in mysql, issue the following:
CREATE USER 'user'@'host' IDENTIFIED BY 'password';

To create a user in mysql and assign grants, issue the following:

grant privilege on database.table to 'user'@'host' [with grant option] [identified by "password"]

Available privileges:
ALL [PRIVILEGES]
ALTER
CREATE
DELETE
DROP
FILE
INDEX
INSERT
PROCESS
USAGE
RELOAD
SELECT
SHUTDOWN
UPDATE

To revoke privileges:
revoke privilege on database.table from user

To revoke grant option:
revoke grant option on
database.table from user


To change a password:
UPDATE mysql.user SET Password=PASSWORD('password')
WHERE User='someuser';

View current user:
select user();

Show user permissions:
show grants for 'username'@'localhost';


http://www.tech-faq.com/reset-mysql-password.shtml

No comments: