Skip to content

Instantly share code, notes, and snippets.

@r6m
Last active August 27, 2018 06:19
Show Gist options
  • Save r6m/0e2c0cb407bee88e7b95da0aec9650dd to your computer and use it in GitHub Desktop.
Save r6m/0e2c0cb407bee88e7b95da0aec9650dd to your computer and use it in GitHub Desktop.
-- create user
create user user;
-- check user
select user, host, password from mysql.user;
-- set password
use mysql;
update user set password=PASSWORD("secret") where User='user';
-- grand all privileges
GRANT ALL PRIVILEGES ON database.* TO 'user'@'%' IDENTIFIED BY 'secret' WITH GRANT OPTION;
flush privileges;
-------- other stuff --------
-- to revoke all privileges from a user
REVOKE ALL PRIVILEGES, GRANT OPTION FROM user;
-- to grand some privileges for specific user and databse
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, REFERENCES, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE ON `database`.* TO 'user'@'%' WITH GRANT OPTION
@r6m
Copy link
Author

r6m commented Aug 27, 2018

remember to flush privileges

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment