MySQL Cheat Sheet

Here are some of the most commonly used MySQL commands:

MySQL Command-Line (CLI)

PurposeSyntaxSample
Running MySQLmysql -uusername -ppasswordmysql -uburnz-pmypass
Importingmysql -uusername -ppassword < filenamemysql -uburnz -pmypass < myNewDB.sql
Dumping or Savingmysqldump -uusername -ppassword database [tables] > filenamemysqldump -uburnz -pmypass myDB > MyDB.sql

mysqldump -uburnz -pmypass myDB table1 > myDBtable1.sql

Basic MySQL Commands

PurposeSyntaxSample
List all databasesSHOW DATABASES;SHOW DATABASES;
Create databaseCREATE DATABASE database ;CREATE DATABASE NewDB;
Use a databaseUSE database ;USE NewDB;
List tables in the databaseSHOW TABLES;SHOW TABLES;
Show the structure of a tableDESCRIBE table ;

SHOW COLUMNS FROM table ;
DESCRIBE Names;

SHOW COLUMNS FROM Names;
Delete a database DROP DATABASE database ;DROP DATABASE NewDB;

Modifying MySQL Commands