---
# System prepended metadata

title: SQL Guide

---

# SQL Guide
---
### Backup [ ]
1. cd to `\mysql\bin\` directory
2. `mysqldump --all-databases > backup.sql -u root -p`
3. Move backup to safe directory
-- To restore: `mysql < backup.myql -u root -p`
4. Copy whole `/mysql/` directory
### Users [ ]
1. cd to `\mysql\bin\` directory
2. `mysql -u root -p`
-- Default password blank
3. delete users: `DROP USER 'user'@'host'`
### Logging [ ]
1. Log into mysql console with root: `SET GLOBAL general_log =1;`
2. the logs are in C:\ProgramFiles\MySQL\MySQL Server X.X\data
3. look a TCP viewer to check the remote connections (port 3306)

### Commands [ ]
1. rotate creds: `SET PASSWORD FOR 'user'@'host' = PASSWORD('ExamplePassword');`
2. Reset root account w/out password: `ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass';
3. Navigate to the mysqld binary and run it with the --init-file flag, specifying the file you created: `mysqld --init-file=C:\\example.txt

