Skip to content

Instantly share code, notes, and snippets.

@jhadeepakkumar14
Forked from rosswd/users.sql
Created April 2, 2018 18:15
Show Gist options
  • Save jhadeepakkumar14/a45e74401c502df1e9529a4d762455e6 to your computer and use it in GitHub Desktop.
Save jhadeepakkumar14/a45e74401c502df1e9529a4d762455e6 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