Bug #9958 USE `somedb` in Export SQL causes ERROR 1049: Unknown database '`somedb`'
Submitted: 17 Apr 2005 12:44 Modified: 31 May 2005 16:43
Reporter: Ondra Zizka Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Administrator Severity:S3 (Non-critical)
Version:1.0.20 OS:Any (All)
Assigned to: Vladimir Kolesnikov CPU Architecture:Any

[17 Apr 2005 12:44] Ondra Zizka
Description:
USE `somedb` in Export SQL causes ERROR 1049: Unknown database '`somedb`'.

How to repeat:
Use MySQL Administrator to export a database. Near the beginning of the sql file, there will be:
-- Create schema `winamplyricscom`
CREATE DATABASE /*!32312 IF NOT EXISTS*/ `somedb`;
USE `somedb`;

But the second line causes an error:
ERROR 1049: Unknown database '`somedb`'

This happens with MySQL server version 4.0.13.

Suggested fix:
Not to use back-apostrophe.
[17 Apr 2005 18:19] Jorge del Conde
Thanks for your bug report
[28 May 2005 16:11] Jorge del Conde
Mike, the problem is it doesn't work just as the customer and the bug report describe the problem.  The user specifically stated that this happened in 4.0.13, and since our GUI tools are 4.0 compatible, we need a fix for this.

root-local/mysql# mysql -uroot
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1 to server version: 4.0.13-standard

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> create database somedb;
Query OK, 1 row affected (0.00 sec)

mysql> USE `somedb`;
ERROR 1049: Unknown database '`somedb`'
mysql>
[28 May 2005 16:11] Jorge del Conde
switching to verified again
[30 May 2005 13:38] Vladimir Kolesnikov
Not a bug. Please use MySQL Administrator to restore the backups.
[30 May 2005 15:10] Ondra Zizka
Do you mean it seriously? If so, this is the most lazy way to close a real bug - finding a workaround.

So, if you really really mean it, then don't call the output "SQL", because it is unusable as SQL; instead, proprietary text file is produced.

Please consider closing this bug for real, that means making that ``'s at least optional. I CAN'T use MySQL Admin to import, and closing bugs by stating "don't do the actions that lead to buggy behavior" really SUCKS.
[31 May 2005 16:43] Vladimir Kolesnikov
Thank you for your bug report. This issue has been committed to our
source repository of that product and will be incorporated into the
next release.

If necessary, you can access the source repository and build the latest
available version, including the bugfix, yourself. More information 
about accessing the source trees is available at
    http://www.mysql.com/doc/en/Installing_source_tree.html
[22 Jan 2007 17:22] [ name withheld ]
I found a workaround:
Use phpMyAdmin to create the database on the server.
Open the .sql file in a text editor.
Comment out (prefix with --) the CREATE... line (line 12)
Save the .sql file (or save it under a new name)
Follow the instructions posted elsewhere, something like:
c:\mysql\bin>mysql -u root -p database > c:\inetpub\database-tweaked.sql
[1 Oct 2008 9:34] David Myers
Vladamir Kolesniv,

I've just experienced what may be same bug in version 5.1.26-rc-community.

I'm essenstially a bit of a newbie to MySQL, and I've been writing a Dbase for my new job.

I've been importing data from file etc, and then running queries, and then exporting those queries to a file.

I then attempted to import more data from a file (here is the link to the file I'm trying to imort ftp://ftp.ncbi.nlm.nih.gov/gene/DATA/gene_info.gz).

I thought at first that everything was going swimminly with my load data infile blah blah blah command, but when I finished the error of above was returned.

In my case the error read:

<ERROR 1049: Unknown database ''\n'>

which seems to imply that the system is looking at something related to my file import or export (which contained the line <lines terminated by '\r\n'>)

When I then attempted to run a query such as <show databases;> an error was returned saying the server was unreachable, even though it was running - as confirmed via the MySQL Admin gui.

I would like to paste the logs but being a newbie I don't know where they are located? if you can point me in the correct direction I will cut and past them in, bearing in mind I may not in fact have any logs, except those set up by default.

I hope the information is helpfull.

Dave