Back to blog
Published 05.05.2026
MySQL Cheat Sheet: Essential Commands for Developers
MySQL is one of the most popular database management systems used in web development. Whether you work with PHP, Laravel, Magento, WordPress, or Node.js, understanding basic SQL commands is an essential skill. This cheat sheet covers the most commonly used MySQL commands that developers and database administrators use on a daily basis.
This cheat sheet contains the most commonly used MySQL commands for everyday web development.
Connecting to MySQL
Connect to the MySQL Server
mysql -u root -p
Connect to a Specific Database
mysql -u root -p database_name
Database Management
List All Databases
SHOW DATABASES;
Create a Database
CREATE DATABASE db
CHARACTER SET utf8mb4
COLLATE utf8mb4_general_ci;
Delete a Database
DROP DATABASE my_database;
Select a Database
USE my_database;
Table Management
List All Tables
SHOW TABLES;
View Table Structure
DESCRIBE users;
Delete a Table
DROP TABLE users;
Rename a Table
RENAME TABLE users TO customers;
Retrieving Data
Select All Records
SELECT * FROM users;
Select Records with a Condition
SELECT *
FROM users
WHERE id = 1;
Updating Data
Update a Record
UPDATE users
SET name = 'Alex'
WHERE id = 1;
Deleting Data
Delete a Record
DELETE FROM users
WHERE id = 1;
Clear a Table
TRUNCATE TABLE users;
Export and Import
Export a Database
mysqldump -u root -p my_database > backup.sql
Import a Database
mysql -u root -p my_database < backup.sql