72 lines
1.2 KiB
Markdown
72 lines
1.2 KiB
Markdown
# Database & SQL Skill
|
|
|
|
## Installed Tools
|
|
- PostgreSQL (docker)
|
|
- MongoDB (docker)
|
|
|
|
## Docker Compose for Databases
|
|
|
|
### PostgreSQL
|
|
```yaml
|
|
services:
|
|
postgres:
|
|
image: postgres:16-alpine
|
|
environment:
|
|
POSTGRES_USER: user
|
|
POSTGRES_PASSWORD: password
|
|
POSTGRES_DB: mydb
|
|
volumes:
|
|
- postgres_data:/var/lib/postgresql/data
|
|
ports:
|
|
- "5432:5432"
|
|
```
|
|
|
|
### MongoDB
|
|
```yaml
|
|
services:
|
|
mongodb:
|
|
image: mongo:7
|
|
environment:
|
|
MONGO_INITDB_ROOT_USERNAME: user
|
|
MONGO_INITDB_ROOT_PASSWORD: password
|
|
volumes:
|
|
- mongo_data:/data/db
|
|
ports:
|
|
- "27017:27017"
|
|
```
|
|
|
|
### PostgreSQL + pgAdmin
|
|
```yaml
|
|
services:
|
|
postgres:
|
|
image: postgres:16-alpine
|
|
environment:
|
|
POSTGRES_USER: admin
|
|
POSTGRES_PASSWORD: secret
|
|
POSTGRES_DB: mydb
|
|
ports:
|
|
- "5432:5432"
|
|
|
|
pgadmin:
|
|
image: dpage/pgadmin4
|
|
environment:
|
|
PGADMIN_DEFAULT_EMAIL: admin@test.com
|
|
PGADMIN_DEFAULT_PASSWORD: admin
|
|
ports:
|
|
- "8080:80"
|
|
```
|
|
|
|
## Common Commands
|
|
```bash
|
|
# PostgreSQL
|
|
docker exec -it container psql -U user -d mydb
|
|
|
|
# MongoDB
|
|
docker exec -it container mongosh -u user -p password
|
|
```
|
|
|
|
## GUI Tools
|
|
- DBeaver (multi-database)
|
|
- pgAdmin (PostgreSQL)
|
|
- MongoDB Compass (MongoDB)
|