Here are some of the most commonly used MySQL commands:
MySQL Command-Line (CLI)
Purpose | Syntax | Sample |
---|---|---|
Running MySQL | mysql -uusername -ppassword | mysql -uburnz-pmypass |
Importing | mysql -uusername -ppassword < filename | mysql -uburnz -pmypass < myNewDB.sql |
Dumping or Saving | mysqldump -uusername -ppassword database [tables] > filename | mysqldump -uburnz -pmypass myDB > MyDB.sql mysqldump -uburnz -pmypass myDB table1 > myDBtable1.sql |
Basic MySQL Commands
Purpose | Syntax | Sample |
---|---|---|
List all databases | SHOW DATABASES; | SHOW DATABASES; |
Create database | CREATE DATABASE database ; | CREATE DATABASE NewDB; |
Use a database | USE database ; | USE NewDB; |
List tables in the database | SHOW TABLES; | SHOW TABLES; |
Show the structure of a table | DESCRIBE table ; SHOW COLUMNS FROM table ; | DESCRIBE Names; SHOW COLUMNS FROM Names; |
Delete a database | DROP DATABASE database ; | DROP DATABASE NewDB; |
Modifying MySQL Commands