Skip to content

Instantly share code, notes, and snippets.

@charlieanstey
Last active May 1, 2018 11:38
Show Gist options
  • Save charlieanstey/ca963b14609a838bbfc6 to your computer and use it in GitHub Desktop.
Save charlieanstey/ca963b14609a838bbfc6 to your computer and use it in GitHub Desktop.
#MySQL common commands
# Create database
CREATE DATABASE name;
# Show databases
SHOW DATABASES;
# Use database
USE database;
---
# Create user
CREATE USER 'user'@'localhost' IDENTIFIED BY 'password';
# Allow user access to entire database
GRANT ALL PRIVILEGES ON base.* TO 'user'@'localhost' IDENTIFIED BY 'password';
GRANT SELECT, INSERT, DELETE ON base.* TO 'user'@'localhost' IDENTIFIED BY 'password';
# Remove user access to database
REVOKE ALL PRIVILEGES ON base.* FROM 'user'@'host'; -- one permission only
REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'user'@'host'; -- all permissions
# Remove password for root on localhost
SET PASSWORD FOR root@localhost=PASSWORD('');
---
UPDATE table SET column=`some value` WHERE something=true;
---
DELETE FROM table WHERE something='this';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment