Skip to content

Instantly share code, notes, and snippets.

@angristan
Last active June 27, 2019 21:33
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save angristan/9ca7c335e09a1c16bd5d581dce17850b to your computer and use it in GitHub Desktop.
Save angristan/9ca7c335e09a1c16bd5d581dce17850b to your computer and use it in GitHub Desktop.
MySQL cheatsheet

Manage databases

Create database

CREATE DATABASE database;

Delete database

DROP DATABASE database;

Manage users

Create user

CREATE USER 'username'@'localhost' IDENTIFIED BY 'password';

Delete user

DROP USER 'username'@'localhost';

Permissions

Types of permissions

  • ALL PRIVILEGES
  • CREATE
  • DROP
  • DELETE
  • INSERT
  • SELECT
  • UPDATE
  • GRANT OPTION

Grant permissions

GRANT ALL PRIVILEGES ON database.* TO 'username'@'localhost';
GRANT type_of_permission ON database_name.table_name TO ‘username’@'localhost’;

Revoke permissions

REVOKE type_of_permission ON database_name.table_name FROM ‘username’@‘localhost’;

Show permissions

SHOW GRANTS username;

Flush privileges

FLUSH PRIVILEGES;
@thomasbnt
Copy link

Thank you 👌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment