Skip to content

Instantly share code, notes, and snippets.

@csdy
Last active May 10, 2024 23:51
Show Gist options
  • Save csdy/bff3aecedc560c8cb47eb43a5edb8c90 to your computer and use it in GitHub Desktop.
Save csdy/bff3aecedc560c8cb47eb43a5edb8c90 to your computer and use it in GitHub Desktop.
MySQL Cheatsheet
-- Create a new database
CREATE DATABASE database_name;
-- Create a new user
CREATE USER 'username'@'%' IDENTIFIED BY 'password';
-- Allow user connections to server
GRANT USAGE ON *.* TO 'username'@'%';
-- Grant user privileges on database
GRANT EXECUTE, SELECT, SHOW VIEW, ALTER, ALTER ROUTINE, CREATE, CREATE ROUTINE, CREATE TEMPORARY TABLES, CREATE VIEW, DELETE, DROP, EVENT, INDEX, INSERT, REFERENCES, TRIGGER, UPDATE, LOCK TABLES ON `database_name`.* TO 'username'@'%';
-- Flush privileges
FLUSH PRIVILEGES;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment