This document provides comprehensive information about Youtarr's database setup, configuration, troubleshooting, and management.
- Overview
- Internal Database (Default)
- External Database Setup
- Database Migrations
- Troubleshooting Database Issues
- Storage Considerations
Youtarr uses MariaDB/MySQL for storing:
- Channel subscriptions and metadata
- Video information and download history
- Job queues and processing state
- Session data for authentication
| Table | Model | Description |
|---|---|---|
channels |
Channel |
YouTube channel information |
Videos |
Video |
Downloaded video metadata |
channelvideos |
ChannelVideo |
Channel <-> video associations |
Jobs |
Job |
Download job queue |
JobVideos |
JobVideo |
Job <-> video associations |
JobVideoDownloads |
JobVideoDownload |
Download progress tracking |
Sessions |
Session |
User authentication sessions |
SequelizeMeta |
NA | Sequelize ORM migration tracking |
- Image:
mariadb:10.3 - Container Name:
youtarr-db - Port: 3321 (both host and container)
- Character Set:
utf8mb4(full Unicode/emoji support) - Default Credentials:
- User:
root - Password:
123qweasd(change in production!) - Database:
youtarr
- User:
volumes:
- ./database:/var/lib/mysql- Data stored in
./databasedirectory on the host - May have permission issues on Synology/QNAP and or virtiofs issues on Apple Silicon macOS, leading to database issues/corruption
volumes:
- youtarr-db-data:/var/lib/mysql- Better compatibility with Synology/QNAP
- Avoids permission issues
- Required for macOS Apple Silicon
- Not easily visible on host
If experiencing permission errors on Synology/QNAP or corruption on Apple Silicon:
IMPORTANT: Changing your DB volume mount will not migrate your existing database! If you are not experiencing problems, leave this setting alone!
-
Stop the stack:
docker compose downor./stop.sh -
Edit
docker-compose.yml:# Change from: volumes: - ./database:/var/lib/mysql # To: volumes: - youtarr-db-data:/var/lib/mysql
-
Add volume definition at bottom of file:
volumes: youtarr-db-data:
-
Restart:
docker compose up -dor./start.sh
-
Edit
.envfile:DB_USER=youtarr DB_PASSWORD=secure-password-here DB_ROOT_PASSWORD=different-secure-password
-
If using non-root user, uncomment in
docker-compose.yml:environment: - MYSQL_USER=${DB_USER} - MYSQL_PASSWORD=${DB_PASSWORD}
-
Restart containers for changes to take effect
Warning: Never expose port 3321 to the internet without proper security measures.
- MariaDB 10.3+ or MySQL 8.0+
- Database with
utf8mb4character set - User with full privileges on the database
- Network connectivity from Youtarr container
Run on your database server:
Note: The example below assumes you are using youtarr for your DB name and youtarr for your DB user.
CREATE DATABASE youtarr
CHARACTER SET utf8mb4
COLLATE utf8mb4_unicode_ci;
CREATE USER 'youtarr'@'%'
IDENTIFIED BY 'your-secure-password';
GRANT ALL PRIVILEGES ON youtarr.*
TO 'youtarr'@'%';
FLUSH PRIVILEGES;Replace '%' with specific IP/network if restricting access.
Edit .env file:
DB_HOST=192.168.1.100 # Your database server IP
DB_PORT=3306 # Your database port
DB_USER=youtarr # Database username
DB_PASSWORD=your-secure-password
DB_NAME=youtarr # Database nameUsing convenience script:
./start-with-external-db.shOr manually:
docker compose -f docker-compose.external-db.yml up -dSimply run the normal start script:
./start.sh- Migrations run automatically on container startup
- Tracked in
SequelizeMetatable - Located in
/app/migrations/inside container - Idempotent - safe to run multiple times
# Use the provided script
./scripts/db-create-migration.sh my-migration-name
# Or use npm directly
npm run db:create-migration -- --name my-migration-name-
Always use helpers for idempotent operations:
const { tableExists, columnExists, createTableIfNotExists } = require('./helpers'); if (!await columnExists(queryInterface, 'videos', 'duration')) { await queryInterface.addColumn('videos', 'duration', {...}); }
-
Test migrations in development first
-
Never modify existing migration files
-
Create new migrations for schema changes
InnoDB: Operating system error number 13- MariaDB container fails to start
- Permission denied errors in logs
- Synology/QNAP NAS: MariaDB runs as UID 999, which may not exist
- macOS Apple Silicon: virtiofs incompatibility with MariaDB 10.3
- Wrong ownership: Database files owned by incorrect user
- Switch to named volume (see above)
- Fix permissions:
# Check current ownership ls -la ./database # Fix ownership (adjust UID:GID as needed) sudo chown -R 999:999 ./database
Duplicate column name 'duration'Table 'channelvideos' already exists- Migration errors after crash/restore
Lost or corrupted SequelizeMeta table causing migrations to re-run
With recent updates, migrations are idempotent and self-healing:
-
Simply restart the container:
docker compose down docker compose up -d
-
If errors persist, manually check:
# Connect to database docker exec -it youtarr-db mysql -u root -p123qweasd youtarr # Check SequelizeMeta SELECT * FROM SequelizeMeta; # If missing, migrations will re-run safely
-
Check container status:
docker ps | grep youtarr-db -
Test connection:
# From host mysql -h localhost -P 3321 -u root -p123qweasd # From Youtarr container docker exec -it youtarr bash mysql -h youtarr-db -P 3321 -u root -p123qweasd
-
Check logs:
docker logs youtarr-db
- Verify credentials match in
.envand database - Check user permissions:
SHOW GRANTS FOR 'youtarr'@'%'; - Ensure user can connect from container IP
- Emoji not saving correctly
- UTF-8 encoding errors
- Question marks in text
Ensure database uses utf8mb4:
-- Check database charset
SELECT DEFAULT_CHARACTER_SET_NAME, DEFAULT_COLLATION_NAME
FROM information_schema.SCHEMATA
WHERE SCHEMA_NAME = 'youtarr';
-- Convert if needed
ALTER DATABASE youtarr
CHARACTER SET utf8mb4
COLLATE utf8mb4_unicode_ci;- Per Channel: ~1-2 KB metadata
- Per Video: ~5-10 KB metadata
- Growth Rate: ~10 MB per 1000 videos