Friday, February 10, 2012

Create a user in mysql and provide complete permission


1. Login as root in mysql
2. create user `username`
Or Create user with password

CREATE USER 'username'@'localhost' IDENTIFIED BY 'password123'


Set password for the mysql user using grant

GRANT USAGE ON *.* TO 'bob'@'%.loc.gov' IDENTIFIED BY 'newpass';

or

SET PASSWORD FOR 'bob'@'%.loc.gov' = PASSWORD('newpass');

Give full permission to the user

GRANT ALL ON *.* TO 'user'@'localhost' IDENTIFIED BY 'pwd'

If you use grant you need flush the privileges

FLUSH PRIVILEGES;

Run below command from root. If other users need to connect to server.
 GRANT ALL ON *.* TO ''@'%' IDENTIFIED BY '';
FLUSH PRIVILEGES;

REVOKE INSERT, DELETE, UPDATE ON db_name.table_name FROM 'user'

In case of AWS RDS to provide permission for any machine to connect, create user and provide grant permission

CREATE USER 'springbot'@'%' IDENTIFIED BY 'SpringBot';

GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, PROCESS, REFERENCES, INDEX, ALTER, SHOW DATABASES, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, TRIGGER ON *.* TO 'springbot'@'%' WITH GRANT OPTION;

No comments :

// Below script tag for SyntaxHighLighter