Skip to content

Instantly share code, notes, and snippets.

@skarllot
Last active December 22, 2016 09:35
Show Gist options
  • Save skarllot/8282881 to your computer and use it in GitHub Desktop.
Save skarllot/8282881 to your computer and use it in GitHub Desktop.
Create MySQL user
-- CREATE USER AND GRANT PRIVILEGE
CREATE USER '[username]'@'localhost' IDENTIFIED BY '[password]';
GRANT [type of permission] ON [database name].[table name] TO '[username]'@'localhost' [WITH GRANT OPTION];
FLUSH PRIVILEGES;
-- PERMISSIONS LIST
-- ALL PRIVILEGES- allows a MySQL user all access to a designated database
-- CREATE- allows them to create new tables or databases
-- DROP- allows them to them to delete tables or databases
-- DELETE- allows them to delete rows from tables
-- INSERT- allows them to insert rows into tables
-- SELECT- allows them to use the Select command to read through databases
-- UPDATE- allow them to update table rows
-- WITH GRANT OPTION- allows them to grant or remove other users' privileges
-- REVOKE PRIVILEGE
REVOKE [type of permission] ON [database name].[table name] FROM '[username]'@'localhost';
-- DROP USER
DROP USER '[username]'@'localhost';
-- Reference: https://www.digitalocean.com/community/articles/how-to-create-a-new-user-and-grant-permissions-in-mysql
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment