Snippets: MySQL: Priviledge

27th April 2021 at 4:24pm
Snippets: MySQL
CREATE USER 'user'@'localhost' IDENTIFIED BY 'password';
ALTER USER 'user'@'localhost' IDENTIFIED BY 'password';

GRANT ALL PRIVILEGES ON base.* TO 'user'@'localhost' IDENTIFIED BY 'password';
GRANT SELECT, INSERT, DELETE ON base.* TO 'user'@'localhost' IDENTIFIED BY 'password';
REVOKE ALL PRIVILEGES ON base.* FROM 'user'@'host'; -- one permission only
REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'user'@'host'; -- all permissions

DROP USER 'user'@'host'