Can't drop MySQL database with bad name

When using the command line interface, I had a finger check in my "source" file and accidentally created a database with an apostrophe as the last character of the name.  I have tried both command line source files and PHP MyAdmin to drop the database.  It either gives me a syntax error on the statement or tells me no database with that name exists.  It even gives me an error when I check the database in the PHP MyAdmin list and click the drop button.

Any idea on how I can kill this beast?

Thanks,
Bruce
springthorpeSoftwareAsked:
Who is Participating?
 
nemws1Connect With a Mentor Database AdministratorCommented:
Ah... you need to end it with a semi-colon, as I did in both my examples. ;-)
0
 
PapertripCommented:
What are the errors?
0
 
nemws1Database AdministratorCommented:
But backtics around the database name:
DROP DATABASE `BadDatabase'`;

Open in new window

0
Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

 
nemws1Database AdministratorCommented:
*Put (not But)
0
 
Pratima PharandeCommented:
rty

DROP DATABASE  IF EXISTS db_name

refer for more details about drop
http://dev.mysql.com/doc/refman/5.0/en/drop-database.html
0
 
springthorpeSoftwareAuthor Commented:
phpMyAdmin - 2.11.9.5

Problem is that when processing MySQL converts ticks, double quotes and single quotes to single quotes. Have tried all of the suggestions so far.  Here are the two errors, with and without ticks in the input:

With ticks (note that the single quote is coverted to two, and ticks are converted to single quotes):
#1008 - Can't drop database 'db_xxx'''; database doesn't exist.

Without ticks (yes, that is an extra space and single quote added by MySQL before the statement was processed.  I entered db_xxx'.)

DROP DATABASE db_xxx ''

MySQL said:  

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '''' at line 1

Other suggestions?

Thanks,
Bruce
0
 
nemws1Database AdministratorCommented:
You said in your initial comments that you had access to both phpMyAdmin and a command line interface.  Please try my suggestion again (backtics) using the command line interface:

 
DROP DATABASE `BadDatabase'`;

Open in new window


I just tested it on one of my databases, and I was able to both create and drop the database with a single quote on the end.
0
 
springthorpeSoftwareAuthor Commented:
nemws1:

The original problem database was created by using a "source" file, e.g. "source [pathname]", not by typing a command directly into mysql DOS interface window.

Not 100% familiar with using the mysql command line, but here's what I tried:

To get to the mysql command prompt, I open a command prompt window, type in
   mysql -u [username] -p [database name]
and enter my password when prompted.  This produces a mysql command prompt.

When I type in the DROP command, there is no error but the database is not dropped.  The DOS prompt then displays an arrow, apparently waiting on the next command:

mysql> DROP DATABASE `db_xxx'`
     ->

Same thinig results from entering the command with a preceeding "go" or "ego".

Typing in another command, even "exit" or "quit" or "help", at that "arrow" prompt does nothing but display another "arrow" prompt.  I have to close the Command Prompt window, open a new one and log back into mysql to make it do anything.

Is there something else I should be doing?

Bruce
0
 
springthorpeSoftwareAuthor Commented:
nemws1:

That did it!!  Many thanks!

Bruce
0
 
springthorpeSoftwareAuthor Commented:
Thanks for taking time to help!
0
 
nemws1Database AdministratorCommented:
Very glad I could help you.  It's always the little things that cause the biggest problems. ;-)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.