Skip to content

Instantly share code, notes, and snippets.

@fzrhrs
Last active August 29, 2015 14:10
Show Gist options
  • Save fzrhrs/6023c13527c880b29824 to your computer and use it in GitHub Desktop.
Save fzrhrs/6023c13527c880b29824 to your computer and use it in GitHub Desktop.
MySQL Cheat Sheet
Connect to MySQL/MariaDB
= mysql -uroot
Create database
= create database db_name;
Drop Database
= drop database db_name;
Connect/use database
= use db_name;
Show tables
= show tables;
Show databases
= show databases;
Show users
= select user from mysql.user;
Create user
= create user 'username'@'localhost' identified by 'user_password';
Grant access/privilleges
= grant all on `db_name`.* to 'username'@'localhost' identified by 'user_password';
To see grants for a specific user
= show grants for 'username'@'localhost';
Select a table/retrieving info;
= select * from table_name where column='values';
Delete table;
drop table_name;
Show table structure;
= describe table_name;
Selecting records;
= select * from table_name;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment