Created
August 8, 2017 17:35
-
-
Save rosswd/eead33fa42b80d225cc5d86f8d4f79cb to your computer and use it in GitHub Desktop.
Managing users in MySQL
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 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