Skip to content

Instantly share code, notes, and snippets.

@rosswd
Created August 8, 2017 17:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save rosswd/eead33fa42b80d225cc5d86f8d4f79cb to your computer and use it in GitHub Desktop.
Save rosswd/eead33fa42b80d225cc5d86f8d4f79cb to your computer and use it in GitHub Desktop.
Managing users in MySQL
-- start mysql daemon
mysql.server start
-- connect as root
mysql -u root -p
-- create a new limited user
-- [field] = placeholder for your situation
CREATE USER '[username]'@'localhost' IDENTIFIED BY '[password]';
GRANT SELECT, INSERT, UPDATE, ALTER ON *.* TO '[username]'@'localhost';
FLUSH PRIVILEGES;
exit
-- connect using new account
mysql -u [username] -p
-- 3 ways to check current granted permissions
SHOW GRANTS;
SHOW GRANTS FOR CURRENT_USER();
SHOW GRANTS FOR '[username]'@'localhost';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment