MetricSign
Start free
High severityschema

MySQL Error:
1049

What does this error mean?

MySQL throws error 1049 when the database name in a connection string, USE statement, or DSN does not exist on the target MySQL server. The server resolves the database name before any query executes, so the connection is rejected immediately — no partial reads occur. In a data pipeline this surfaces as a failed linked service test in Azure Data Factory, a dbt profile that cannot compile, or a Power BI DirectQuery dataset that errors on refresh. The engineer sees a red pipeline run with exit code 1049 and the message 'Unknown database \'your_db_name\''. Common triggers include a dropped database, a renamed database where connection strings were not updated, or a deploy pointing at the wrong environment.

Common causes

  • 1The database was dropped and never recreated. A DBA or migration script issued DROP DATABASE and downstream services were not updated. Every subsequent connection attempt fails until the database is restored or the connection string is changed.
  • 2A typo in the database name in the connection string or dbt profile. MySQL on Linux performs a case-sensitive match because database names map to filesystem directories under the datadir. 'Analytics' and 'analytics' are two different databases.
  • 3Connecting to the wrong MySQL host. The pipeline is pointed at a staging or dev instance where the database does not exist, while the intended target is the production server. This is especially common after copying a connection string from one environment and forgetting to change the host.
  • 4A database rename was performed by dumping and recreating under a new name, but at least one connection string — in an ADF linked service, a dbt profiles.yml, or a Power BI gateway configuration — still references the old name.
  • 5The database exists but on a different MySQL instance or port. A multi-tenant setup may run several MySQL processes; the pipeline connects to port 3306 while the target database lives on 3307.
  • 6A migration or CI/CD job that creates the database failed silently before the pipeline ran. The pipeline assumes the database was provisioned but the CREATE DATABASE statement never executed successfully.
  • 7The MySQL user account used by the pipeline has been granted access to a differently-named database (e.g. 'app_prod') but the connection string specifies 'appdb_prod'. The 1049 error fires before MySQL even evaluates user permissions.

How to fix it

  1. 1Step 1: From a MySQL client with admin access, list all databases on the target server to confirm whether the database exists at all: `SHOW DATABASES;`
  2. 2Step 2: If the database is missing and should exist, create it with the correct character set: `CREATE DATABASE your_db CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;`
  3. 3Step 3: If the database exists but under a different name (e.g. a rename happened), compare the exact string in SHOW DATABASES output against your connection string. On Linux MySQL, fix the casing in the connection string — do not rename the database to match a typo.
  4. 4Step 4: In Azure Data Factory, open the linked service, update the Database Name field, and click Test Connection before saving. ADF caches the linked service configuration; a successful test confirms the new name is correct.
  5. 5Step 5: In a dbt project, open profiles.yml, correct the schema or database field for the target environment, then run `dbt debug` to verify the profile connects: `dbt debug --target prod`
  6. 6Step 6: For Power BI, open the Power BI Service → Settings → Datasets → select the dataset → Data source credentials → edit the connection string to match the correct database name, then trigger a manual refresh to confirm.
  7. 7Step 7: After fixing the connection string, verify that the MySQL user has CONNECT privileges on the newly specified database: `SHOW GRANTS FOR 'pipeline_user'@'%';` — grant access if the database was freshly created: `GRANT SELECT, INSERT, UPDATE ON your_db.* TO 'pipeline_user'@'%'; FLUSH PRIVILEGES;`

Example log output

ERROR 1049 (42000): Unknown database 'analytics_prod'
[ADF] Activity failed: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown database 'analytics_prod' (error code: 1049)
[dbt] Database Error: (1049, "Unknown database 'analytics_prod'")

Frequently asked questions

MySQL error 1049 fix — what is the fastest way to resolve this in production?

Run SHOW DATABASES; on the target MySQL server to get the exact list of existing database names. Compare that list to what your connection string specifies. In most cases the fix is a one-character typo correction or a casing mismatch on a Linux server. Update the connection string in your linked service or profiles.yml and test the connection before re-running the pipeline.

Will MySQL 1049 retry automatically in ADF or will it fail immediately?

ADF treats error 1049 as a non-retryable connection error. The activity fails immediately without retrying because no amount of retrying will make a non-existent database appear. You must fix the connection configuration before triggering another run.

Is MySQL database naming case-sensitive?

On Linux MySQL, database names are case-sensitive by default because they map to filesystem directories under the datadir. 'Analytics' and 'analytics' are treated as two different databases. On Windows MySQL, names are case-insensitive. If you migrated from Windows to Linux, case mismatches in connection strings will produce error 1049.

How do I safely rename a MySQL database without breaking pipelines?

MySQL has no RENAME DATABASE command. The standard procedure is: (1) dump the source database with mysqldump, (2) create the new database with the correct name, (3) import the dump into the new database, (4) update all connection strings in ADF linked services, dbt profiles, Power BI gateways, and application configs, (5) verify all pipelines connect successfully, then (6) drop the old database. Doing step 6 before step 4 causes error 1049 across all dependent systems.

Source · dev.mysql.com/doc/mysql-errors/8.0/en/server-error-reference.html

Other schema errors