mysqldump "Unknown database" (1049) Error During Backup

Summary

When JetBackup attempts to back up a cPanel account, it may fail with the following error:

mysqldump: Got error: 1049: Unknown database when selecting the database

This occurs when a database has been deleted directly from MySQL but remains registered in cPanel's internal ownership records, causing JetBackup to attempt a backup of a database that no longer exists.

Root Cause

JetBackup does not query MySQL directly to discover which databases belong to an account before each backup. Instead, it relies on the cPanel API to determine which databases should be included.

This means that if a database is deleted from MySQL by any method other than the two supported cPanel channels, cPanel's user-database map will still list that database as belonging to the account. JetBackup will then attempt to back it up via mysqldump, which returns the 1049: Unknown database error because the database no longer exists in MySQL.

How to Reproduce / Verify

Use the following whmapi1 command to confirm that cPanel still reports the deleted database as associated with the account: (Replace <cpanel_username> with the cPanel account)

whmapi1 list_databases \
  api.filter.enable=1 \
  api.filter.a.field=engine \
  api.filter.a.arg0=mysql \
  api.filter.a.type=eq \
  api.filter.b.field=cpuser \
  api.filter.b.arg0=<cpanel_username> \
  api.filter.b.type=eq

If the missing database appears in the output, cPanel's ownership records are out of sync with MySQL — confirming this is the root cause.

Resolution

To properly remove a database so that both MySQL and cPanel's user-database map are updated, use one of these two supported methods only:

Option 1 — cPanel "Manage Databases" GUI

  1. Log in to the cPanel account.
  2. Navigate to Databases → MySQL Databases 
  3. Use the Delete option next to the database under the Manage Databases section.
  4. Re-run the backup job and verify the error is resolved. 

Option 2 — UAPI via Command Line

Run the following command as root (replace user1234 and wp_userdb123 with the actual username and database name):

uapi --user=user1234 Mysql delete_database database=wp_userdb123

Then, Re-run the backup job and verify the error is resolved. 

Both methods remove the database from MySQL and update cPanel's internal ownership map, preventing JetBackup from attempting to back up a non-existent database.

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

JetBackup 5 for Linux - Disk Usage/Inode Usage shows N/A

Since JetBackup 5 for Linux does not have an associated panel to gather account information,...

Rsync Backing Up Account Fails - Error: overflow

There have been some reports of accounts failing to back up with errors similar to this:[ERROR]...

Database Backup Errors: only_full_group_by

While performing a Database Backup, you may encounter the following error: Expression #1 of...

Exclude List for FTP/SFTP Destinations does not work

FTP/SFTP destinations are known to have limitations with their commands and file pathing...

Extra Backups Appearing On JetBackup

There are many reasons extra backups can appear on JetBackup. JetBackup 4 has Manual Backups and...