Bug #6753 mysqldump adds back-quotes to the USE statement
Submitted: 22 Nov 2004 18:56 Modified: 23 Nov 2004 18:50
Reporter: Tom Suzuki Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server: mysqldump Command-line Client Severity:S3 (Non-critical)
Version:4.1.7 OS:Linux (Linux)
Assigned to: CPU Architecture:Any

[22 Nov 2004 18:56] Tom Suzuki
Description:
After backing up the entire databases using mysqldump, mysql fails to restore the database from the backup file that mysqldump generated.

How to repeat:
 In the following example, a database called log is archived in the file '/tmp/mysql417_bkup.dat'.

# ./mysqldump --all-databases > /tmp/mysql417_bkup.dat 
# mysql --socket=/tmp/mysql.sock < /tmp/mysql417_bkup.dat 
ERROR 1049 at line 21: Unknown database '`log`'
# 

It was found that USE LOG; had back-qoutes surrounding the statement in the generated backup file.

On the command line, if you change database to mysql with back-quotes surrounding mysql, it is not accepted either.

mysql> use `mysql`;
ERROR 1049: Unknown database '`mysql`'
mysql> 

MySQL 4.1.1 alpha does not have this problem.

Suggested fix:
The back-quotes should be removed from the SQL statement USE `<database_name>` that mysqldump generates.
[23 Nov 2004 18:50] MySQL Verification Team
Hi,

Thank you for the report, but this is not a bug in the mysqldump. mysqldump should quote database names in USE statement. This is expected behaviour.
This was a bug in the mysql client, that is already fixed
[23 Nov 2004 19:24] Tom Suzuki
If that is the case, it seems inconsistent that it cannot execute the backup file successfully as described in Section 8.8 The mysqldump Database Backup Program, but with --all-databases set. Perhaps --all-databases option is not supported? Thank you for your update.