Skip to content

Instantly share code, notes, and snippets.

@rwp0
Last active July 31, 2022 18:26
Show Gist options
  • Save rwp0/f68c013a4c25cb72816869180e95a57f to your computer and use it in GitHub Desktop.
Save rwp0/f68c013a4c25cb72816869180e95a57f to your computer and use it in GitHub Desktop.
MySQL create database user and grants privileges with a single command
-- create database user and grant privileges with a single command
GRANT ALL PRIVILEGES
ON TABLE <database>.*
TO <user>
IDENTIFIED BY <password>;
SHOW GRANTS FOR <user>;
-- output: GRANT ALL PRIVILEGES ON `<database>`.* TO '<user>'@'%'
-- % is the default host for the user (ie. IP address or hostname where the user connects from)
-- OR:
-- CREATE USER <user> IDENTIFIED BY <password>;
-- GRANT ALL PRIVILEGES ON <database>.* TO '<user>'@'%';
-- qv. https://dev.mysql.com/doc/refman/5.6/en/grant.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment