root@sparrow:~/writeups$ cat mysql.md
// web
MySQL
22 Jul 2026
· 1 min read
The mysql client connects to MySQL/MariaDB servers (port 3306, very common on HTB machines) to enumerate databases and extract data once you have credentials — or if the service doesn't require authentication.
| Type | CLI |
| Default port | 3306 |

Connecting
mysql -u <user> -p # prompts for password
mysql -u <user> -p -h <IP> # remote host
mysql -u <user> -p <db_name> # jump straight into a database
Databases and tables
SHOW DATABASES;
USE <db_name>;
SHOW TABLES;
DESCRIBE <table>;
SELECT * FROM <table> LIMIT 10;
Insert / update / delete
INSERT INTO <table> (col1, col2) VALUES ('value1', 'value2');
UPDATE <table> SET col='new' WHERE id=1;
DELETE FROM <table> WHERE id=1;
Create / drop
CREATE DATABASE <name>;
CREATE TABLE example (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(50)
);
DROP TABLE <table>;
DROP DATABASE <name>;
EXIT;
Responsible use
These commands are for systems you own or have explicit written authorisation to test (labs, CTFs, contracted engagements). Using them against third-party infrastructure without permission is illegal in most countries.