Last active
August 29, 2015 14:10
-
-
Save fzrhrs/6023c13527c880b29824 to your computer and use it in GitHub Desktop.
MySQL Cheat Sheet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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