×


MySQLdump: got error :1049 :unknown database - Fix it Now ?

Sometimes while performing WHM backups, users notice an error "mysqldump: Got error: 1049: Unknown database". This can occur when the database does not exist in MySQL.

In other cases, this error happens when you specify the password on the command line with -p flag and there is a space between -p and password in the process of trying to dump the database.

Here at Ibmi Media, as part of our Server Management Services, we regularly help our CUstomers to perform related WHM / cPanel queries.

In this context, we will look into how to resolve "mysqldump: Got error: 1049: Unknown database" error during the WHM backup.


Key causes of "MySQLdump: got error :1049 :unknown database" error ?

MySQLdump helps to perform the logical backups, generating a set of SQL statements like DDL, DML for reproduced backup Schema. It dumps one or more MySQL databases for backup or transfers to another SQL server.

We can also generate output in CSV, other delimited text or XML format. The main drawback of MySQLdump is that the restoration procedure can take a long time to execute if the database is very large.

While performing WHM backups, at times, we can see the following error in the backup log:

The backup process encountered the following error: The backup process on "hostname.example.server" encountered an error.

[2021-05-10 02:25:26 -0600] mysqldump: Got error: 1049: Unknown database ‘example_database’ when selecting the database

Basically, this error shows that the related database exists in a cPanel user's database map, but the database does not exist in MySQL.


How to resolve the error "MySQLdump: got error :1049 :unknown database" ?

To begin, start by checking whether the database exists within MySQL. You can do this by running the following command as the root user via SSH:

$ mysql -e "show databases;" | grep sample_database

Replace sample_database with the database found within the backup error in the backup logs. We can find the backup logs within /usr/local/cpanel/logs/cpbackup.

If the above command does not display any results, it indicates that the database does not exist in MySQL.

Thus, In order to correct the backup errors, we have to remove the databases that do not actually exist in MySQL from cPanel.

For this, we initially log in to the cPanel account for the particular database user. Then, we navigate to the Databases section and then click on the MySQL Databases option.

Now, all you need to do is to delete the corresponding database from the current database section.


[Need urgent assistance in fixing cPanel errors? – We're available 24*7. ]


Conclusion

This article covers the best method to fix the MySQL database error, "MySQLdump: got error :1049 :unknown database".

Generally, this error happens while performing cPanel backups and it simply indicates that the database does not exist in MySQL.


How to fix mysqldump unknown database when selecting the database?

In cases where this error occurs when you specify the password on the command line with -p flag and there is a space between -p and password.

For example, if you want to dump the database named wpdb using the user "root" and password "your-password".

Fix this error, by specifying the password with no space after -p switch as shown below:

mysqldump -u root -pyour-password wpdb > wpdb_backup.sql