Solved

Can't drop MySQL database with bad name

Posted on 2011-09-18
11
768 Views
Last Modified: 2012-06-27
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
0
Comment
Question by:springthorpeSoftware
11 Comments
 
LVL 21

Expert Comment

by:Papertrip
Comment Utility
What are the errors?
0
 
LVL 23

Expert Comment

by:nemws1
Comment Utility
But backtics around the database name:
DROP DATABASE `BadDatabase'`;

Open in new window

0
 
LVL 23

Expert Comment

by:nemws1
Comment Utility
*Put (not But)
0
 
LVL 39

Expert Comment

by:Pratima Pharande
Comment Utility
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
 

Author Comment

by:springthorpeSoftware
Comment Utility
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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 23

Expert Comment

by:nemws1
Comment Utility
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
 

Author Comment

by:springthorpeSoftware
Comment Utility
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
 
LVL 23

Accepted Solution

by:
nemws1 earned 250 total points
Comment Utility
Ah... you need to end it with a semi-colon, as I did in both my examples. ;-)
0
 

Author Comment

by:springthorpeSoftware
Comment Utility
nemws1:

That did it!!  Many thanks!

Bruce
0
 

Author Closing Comment

by:springthorpeSoftware
Comment Utility
Thanks for taking time to help!
0
 
LVL 23

Expert Comment

by:nemws1
Comment Utility
Very glad I could help you.  It's always the little things that cause the biggest problems. ;-)
0

Featured Post

Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

Join & Write a Comment

Suggested Solutions

Loading csv or delimited data files to MySQL database is a very common task frequently questioned about and almost every time LOAD DATA INFILE comes to the rescue. Here we will try to understand some of the very common scenarios for loading data …
Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now