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
Delete a database DROP DATABASE database ;DROP DATABASE NewDB;
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;

Modifying MySQL Commands

Spread the love

Leave a Reply

Your email address will not be published. Required fields are marked *

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.