Ravi Sir's Cyber Security Cards › Revision Cards
MySQL Cheat Sheet
MySQL Cheat Sheet A quick revision of MySQL: connect, schema, SELECT, writes, keys, safe updates, GRANT and backups. Use a least-privilege app user. Keep SQL_SAFE_UPDATES on. Use prepared statements for all user input. Never expose MySQL or RDS to the public internet. These habits stop most database

Read card text
What this card says
What it is
A quick revision of MySQL: connect, schema, SELECT, writes, keys, safe updates, GRANT and backups.
Key habits
Use a least-privilege app user. Keep SQL_SAFE_UPDATES on.
Use prepared statements for all user input.
Why it matters for security
Never expose MySQL or RDS to the public internet.
These habits stop most database attacks.
| Red team (attacker) does | Blue team (defender)… |
|---|---|
| String-concats user input into SQL (SQLi) | Prepared statements / PDO (ch29); WAF as layer; least DB… |
| Connects as root from PHP | Dedicated app@localhost with minimal GRANT |
| Leaves 3306 open on public EIP / 0.0.0.0 | bind-address=127.0.0.1; SG/firewall; ss -tulpn proof |
| Runs UPDATE without WHERE in panic | SQL_SAFE_UPDATES=1; backups; change tickets |
Learn more in the lesson: 49.3 MySQL Cheat Sheet