473,385 Members | 1,409 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Mysql 4: Invalid database name (howto delete?)

fopetesl
"show databases"
Expand|Select|Wrap|Line Numbers
  1. Databases
  2. usernames.May2007
  3. usernames.June2007
  4. usernames
When I execute "use usernames.May2007" I get error:
Expand|Select|Wrap|Line Numbers
  1. Error 1102 (42000) : Invalid database name 'usernames.May2007'
I don't now need to keep the '..2007' databases but how do I delete them?
I get a similar error when I execute "drop usernames.May2007"
Feb 18 '09 #1
8 10326
Atli
5,058 Expert 4TB
Hi.

To use special and reserved characters in database/table/column names, enclose them in back-ticks.
(Note, these are not the same as single-quotes!)
Expand|Select|Wrap|Line Numbers
  1. USE `weird.database name!`;
  2. SELECT
  3.  `weird.column.name`
  4. FROM 
  5.  `weird table name`;
  6.  
But it's good practice to always use names that do not require the back-ticks.
Feb 18 '09 #2
Thanks, Atli. But doesn't work. :(
So is either wrong back-tick, isn't recognised or I don't have it on my UK keyboard.
On mine it's just above the <tab> key. Right? like: `````````
Feb 18 '09 #3
Atli
5,058 Expert 4TB
Yep, that is the right character.

As it turns out, you can not use a dot in database or table names.
(See 8.2. Schema Object Names)

I guess the only way to change the name of the database would be to rename the actual data directory. Each database on your MySQL server is stored in it's own directory under the MySQL data directory. If you rename the directory, the name of the database will also change.

So, you would have to find out where that directory is.
If you tell us which OS you are using we might be able to help.
Feb 18 '09 #4
You got it, Atli !!
What threw me was that I had the databases as named in
Expand|Select|Wrap|Line Numbers
  1. /var/lib/mysql
and had already deleted the '.' ones without any apparent change.
So I dug some more and found the same databases in
Expand|Select|Wrap|Line Numbers
  1. /usr/local/mysql/data
so I deleted the offending directories and restarted mysql .. voila! Offending databases gone. :)

So a) why were there apparent copy databases in /var/lib/mysql? And of what use?
b) why doesn't the back-tick `name` work?
c) what other methods are available to rename badly named databases?

Thanks for your leaders.

Oh. Ubuntu Breezy Badger
Feb 18 '09 #5
Atli
5,058 Expert 4TB
@fopetesl
  1. On my Ubuntu 8.10 installation, MySQL stores it's data in /var/lib/mysql.
    I tried renaming the directories there, and the MySQL server reflected the change instantly.
    I simply installed my MySQL server from the apt package manager. Maybe you did something else?
  2. It seems that even when enclosed in back-ticks, MySQL checks the name for invalid characters. And because a dot is not allowed in database and table names, it will fail the validation and bail out before the command is executed.
  3. Prior to MySQL 5.1, MySQL had no way of renaming databases. The best method to get around this seems to be creating new databases and copying the contents of an old one over using mysqldump. Somewhat like:
    Expand|Select|Wrap|Line Numbers
    1. mysqldump oldDatabase -p | mysql -D newDatabase -p
    In MySQL 5.1, they changed the ALTER DATABASE command, and added a RENAME DATABASE command.
    (The RENAME command seems to have serious limitations, however)
Feb 18 '09 #6
So. I guess what you are intimating is that somewhere mysql (on my system) has been redirected to /usr/local/mysql/data and away from the usual(?) /var/lib/mysql.
I certainly haven't done anything to effect this - I don't yet have sufficient knowledge.

The puzzling aspect is the mirror status of the databases and deleting from ... lib/mysql has no apparent effect.

The system has remained, or so I believe, stable for years.

What I need to do now is to massage the backup-to-flash-drive code to reflect the real database location!

Thanks for your help. Something new every day :-))
Feb 18 '09 #7
Atli
5,058 Expert 4TB
@fopetesl
That would be my guess.

Although, I have never had MySQL 4 installed on Ubuntu, I've only ever used MySQL 5, so it could be that the /usr/local/mysql/data directory is the correct location.
Somebody may have installed and uninstalled MySQL 5, leaving the /var/lib/mysql data behind... I don't really know.

But... the location used by MySQL can be found in the "my.cnf" file, which is usually located in /etc/mysql/ on Ubuntu. Look for the "datadir" directive.
Feb 18 '09 #8
Hmmm. Interesting.
In /etc/mysql there are four files:
Expand|Select|Wrap|Line Numbers
  1. dead.letter
  2. debian-log-rotate.conf
  3. debian-start (executable)
  4. debian.cnf
None of them make reference to any directories. Seem to be start-up scripts only.

So I did a search for "my.cnf" :- not on my system.
Googling (briefly) confirms what you see: "my.cnf" should be in "etc/mysql"

The system runs OK as is but it would be reassuring to know just why my databases are in "/usr/local...."? I have a small concern that I may be storing problems for the future.
Feb 19 '09 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

11
by: Bruce A. Julseth | last post by:
Newbie Question: Is there a way to import MS Access into MySQL? Maybe create a CSV or something. If so, what would be the SQL to do this? Thanks... Bruce
0
by: leegold2 | last post by:
I can connect in the php by using 'root' and the root pw. But when I tried adding a user ( sarah ) with GRANT I cannot connect from php. The php is simple, what am I overlooking? Again putting the...
11
by: Mike MacSween | last post by:
My client has an MS Access database application on her local machine. I have full access to that in terms of changing the design. I've got a simple PHP/MySql application on shared hosting, so no...
5
by: Tom Martin | last post by:
I'm a Java Web developer NEWBIE that has inherited a website that fails every 2 hours due to poor connection pooling between Tomcat 4.0.6 and mySQL. In efforts to resolve this problem, I've...
0
by: Mike Chirico | last post by:
Interesting Things to Know about MySQL Mike Chirico (mchirico@users.sourceforge.net) Copyright (GPU Free Documentation License) 2004 Last Updated: Mon Jun 7 10:37:28 EDT 2004 The latest...
9
by: Dejan | last post by:
Hy, Sorry for my terreble english I have this simple code for deleting rows in mysql table... Everything works fine with it. So, what do i wanna do...: my sql table looks something like...
15
by: Cheryl Langdon | last post by:
Hello everyone, This is my first attempt at getting help in this manner. Please forgive me if this is an inappropriate request. I suddenly find myself in urgent need of instruction on how to...
6
Atli
by: Atli | last post by:
This is an easy to digest 12 step guide on basics of using MySQL. It's a great refresher for those who need it and it work's great for first time MySQL users. Anyone should be able to get...
221
Atli
by: Atli | last post by:
You may be wondering why you would want to put your files “into” the database, rather than just onto the file-system. Well, most of the time, you wouldn’t. In situations where your PHP application...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.