Mysqldump reports 'Unknown database' when database contains views with spaces in their names
lirwin3007 opened this issue · comments
I've spent a long time debugging this, so I thought I'd open up an issue in case it helps anyone in the future, and to report a possible bug within the package.
Our database backup suddenly started failing with a log like:
Dumping database production...
...
mysqldump: Got error: 1049: Unknown database 'entities' when selecting the database
This was strange because it was complaining about an entites
database when I was trying to dump production
!
After a lot of debugging, I found that the package automatically adds any views that are present in the database to the database.connections.mysql.dump.excludeTables
config value.
It turns out one of our support team had added a view to the database called show_all entities
- putting a space before 'entities' instead of an underscore. As a result, show_all entities
was being passed to mysqldump, and I assume mysqldump was not interpreting this as intended, and was instead trying to exclude a view called show_all
and find a database called entities
I've resolved this for us by telling the support worker that under no circumstances should they be manually creating anything in the database 😆 but I thought it best to still open this issue so anyone encountering a similar problem could find some information on the cause