I was using mysqldump to backup mysql data from one server to another. It was working well until recently after I added a few more lines to my command line backup script- basically to backup more tables. In the script I have individual lines to backup single tables in this example format:
source_server --compress --skip-lock-tables --lock-tables
=false database_to_backup table_to_backup | mysql -u
Whenever cron ran the script, I was getting the error:
ERROR 1049 (42000): Unknown database 'database_to_backup'
mysqldump: Got errno 32 on write
It turned out that I had a typo for the name of the local database which did not exist. Basically my destination database has a different name than the database to be backed up, but I still used the same name. Dumb-dee-dum-dumb. So if you are having this error double check your spelling/existence of the local target database you are doing the backup to!