dataiotech Labs
dbaguidedbaguideDBAdataxtoolsdataopsphere
Home/Error Library/mysql-1049-unknown-database
MySQL
MySQL 8.0 - 8.4Schema & Migration
3 min read
ERROR 1049 (42000): Unknown database 'prod_v2'

MySQL Unknown Database Error: Case-Sensitivity Traps, Pre-Migration DDL Gaps & Flyway/Liquibase Best Practices

Addressing 1049 errors caused by casing mismatch, missing pre-migration databases, and dump restore context errors with idempotent scripts.

Reviewed by:Senior Database Architect & SRE (dataiotech Labs)
Tested Versions: MySQL 8.0 / 8.4 LTS / 9.0

Operational Verification & Reliability Metadata

Last Technical Review: 2 Kasım 2026
Tested VersionsMySQL 8.0.36, 8.4.1 LTS
Required PrivilegesCREATE DATABASE privilege
Risk Assessment
LowMissing database stops deployment executions
Expected OutputTarget database listed in SHOW DATABASES
Rollback Procedure:DROP DATABASE IF EXISTS prod_v2;
MySQL Docs: CREATE DATABASE Syntax
First 60 Seconds Emergency Protocol:

The error string is a symptom, not the root cause. Do not restart the server blindly. Run the diagnostic queries below to pinpoint the actual failure mode.

▸Symptom

Applications fail during bootstrap or during dump restore operations with:

plaintext
ERROR 1049 (42000): Unknown database 'prod_v2'

▸What You See in Production

CI/CD deployment pipelines break immediately on migration steps, or application containers fail readiness checks.


▸Root Cause Matrix

ProbabilityRoot CauseDescription
%60Missing Pre-Migration DatabaseMigration engines expect pre-existing target databases before executing DDL.
%25Case Sensitivity TrapsLinux environments distinguish casing under lower_case_table_names=0.
%15Hardcoded `USE` Clauses in DumpsIngested dumps force context switching to non-existent schemas.

▸EMERGENCY RUNBOOK (0-5 min)

sql
-- 1. Inspect existing schemas SHOW DATABASES; -- 2. Create missing target database with proper charset CREATE DATABASE IF NOT EXISTS prod_v2 CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci; -- 3. Grant application user permissions GRANT ALL PRIVILEGES ON prod_v2.* TO 'app_user'@'%'; FLUSH PRIVILEGES;

▸PERMANENT BLUEPRINT

  1. 1Standardized Encodings: Enforce utf8mb4 and utf8mb4_0900_ai_ci uniformly.
  2. 2Idempotent CI/CD Ingestion: Enforce automated pre-flight creation hooks in migration runners.

▸Verification

sql
SELECT schema_name, default_character_set_name FROM information_schema.schemata WHERE schema_name = 'prod_v2';

Other Database Error Triage Playbooks

Other battle-tested diagnostic guides for high-severity database errors.

All Errors (82)