I keep getting the error "mysqldump: Got error: 1102: Incorrect database name" when trying to backup databases

Viewed 36

I am trying to back up all the WordPress related databases on the server, but I keep running into this particular error

I am storing all the WordPress databases in a variable name like so

> databases=$(mysql -u root -p --vertical --skip-column-names -e "SHOW DATABASES LIKE 'wp_%'" | grep -i wp | tr '\n' ' ')
> echo $database # now contains something like wp_1 wp_2 wp_3 ...

So in order to back up the databases, I am running this command

> mysqldump -u root -p --add-drop-database --add-drop-table --lock-tables --add-locks --add-drop-trigger --disable-keys --databases $databases > wordpress_databases.sql 

But I am getting this error

mysqldump: Got error: 1102: Incorrect database name 'wp_1 wp_2 wp_' when selecting the database

What am I missing here?

1 Answers

I think that error is somehow occurred due to the names of some files in the directory where you are running the "mysqldump" command from, Files with names starting with a "dot" or specials characters like it, An update to the used MySQL version can fix the issue or renaming these files and rerun the command, You can have a look at the following post for more info: https://bugs.mysql.com/bug.php?id=57049

Related