mysql: table disappeared. I have never dropped it - mysql

I was trying to drop a column of my table but I got an error message.
After a few attempts, suddenly the table disappeared, but I have never dropped it.
I was in the page "table structure" of phpmyadmin, I clicked "drop column" and an error message appeared, which told me "table doesn't exist".
This proves that I dind't drop it, because if I was working in the page table structure of the table it means that the table was there.
And I don't know what happened, seems totally irrational to me.
The table simply disappeared (autodropped) while I was working on it.
However, doesn't matter so much what happened. The question is: how can I restore the table? Given the fact that I didn't drop the table, maybe the table is still somewhere?

It's possible that the table was dropped and an error occured after the table got dropped. Double triple check in PHPMyAdmin, but I think your table has gone forever.
To prevent this happening in the future, always run daily backups on your site and store them in a location that's not on the server hosting your database.

Related

MySQL: ERROR 1146 table doesn't exist...although it does

I am following an example in a textbook that seems to gloss over the portion about setting up a simple MySQL. (I've noted some errors but I believe I've been able to correct them). Despite seemingly entering everything correctly in the terminal and the table existing, I get the 1146 error every time I attempt to describe the table.
NOTE: I am running MySQL v5.5.15 on Windows 7 VM in VirtualBox (as per the example I'm following in my book). This is a FRESH SQL DB here, just so we're clear.
CREATE DATABASE moviedb;
USE moviedb;
CREATE TABLE creditcards(
-->id varchar(20) DEFAULT NULL,
-->first_name varchar(50) DEFAULT NULL,
-->last_name varchar(50) DEFAULT NULL,
-->expiration date DEFAULT NULL);
DESCRIBE moviedb;
ERROR 1146 (42S02): Table 'moviedb.moviedb' doesn't exist
Now, the first thing that jumps out at me is that it says 'moviedb.moviedb' doesn't exist, which leads me to believe that it's looking for an element in 'moviedb' called 'moviedb' which I imagine shouldn't exist because I didn't create it. Do I need to "go back" to the "root" in order to display the contents of the moviedb? Although I'm following an example from a book, I'm also following along an arbitrary YouTube video that didn't have to enter any commands between CREATE TABLE and DESCRIBE.
If I attempt to move to a different table and then describe the moviedb, I have the same issue.
I also ran SELECT * FROM moviedb; and that didn't seem to change anything.
Here is the full screenshot from my terminal, just for transparency. I know that I'm not using proper syntax, but...I'm not a perfect man. If there's any chance that THIS is what is causing the error, I'll gladly redo it correctly, however I used proper syntax the first time and got the same error. This is take 2:
I imagine I'm doing something silly because I'm on an old version of MySQL and syntax might be slightly different.
Thank you all in advance for any input you have.
-Joe
The DESCRIBE command takes a table name and you are giving it a database name. Of course, MySQL doesn't know that and thinks you are looking for a table with the name moviesb. You need to use DESCRIBE creditcards instead.
For future google searches.
When your database is on the server and if you are controlling your database through cPanel, You gotta care about the case (Eg:- sells and SELLS are not the same). Try to match the database table name cases always.

Can't drop table after creating table with wrong engine

I'm trying to drop a table containing several hundred thousand column-based records. Normally when creating the database I use a column-based engine (infinidb) but in this case I forgot to include the ENGINE statement. So the database is pretty much unusable for my needs. Now I have a database full of tables that are taking forever to drop (it's been two hours and nothing has happened). I tried the ALTER TABLE table ENGINE=INFINIDB command but again, it's taking forever (see above re: two hours). EDIT: The first command I tried was DROP TABLE. It hung with every single table. Then I tried the ALTER command in case that was faster for some reason, but it wasn't.
Is there another way to get rid of this database? E.g. manually going into the /mysql/ directory and deleting the database? I guess I could just rename it and leave it, but I'd rather get rid of it entirely so it's not taking up space.
First of all you said Can't drop table. But in post you mentioned ALTER TABLE table ENGINE=INFINIDB.
But DROP != ALTER it is two different things.
So you can do following:
CREATE new table with same structure but engine you need.
copy(UPDATE) data from old table to the one you just created.
DROP old table.
RENAMErename new one to old name
It turned out that another process (a website) was using this database and had a couple of queries that got 'stuck' in the SQL server and caused the table to hang due to the database using the wrong engine, which I'm assuming was InnoDB since I didn't specify an engine when I initially used the "CREATE TABLE table1 AS SELECT * FROM table2" command. We finally managed to wipe the database and start over. Thanks for your help.

Get structure of broken table

Is there a way to salvage the structure of a broken mysql table?
I've been searching, but can't find anything other than repair table x.
When I issue a select on the table, the server responds: Incorrect key file for table 'click'; try to repair it
But repairing doesn't work. MySql comes back with a Msg_text of Corrupt. Gee, I kinda knew that already.
The data in the table isn't all that important and can be lost, but I do want to salvage the table structure which I can't get (describe click): Incorrect key file for table 'click'; try to repair it.
I was hoping truncate might solve my problem, but alas: Table 'click' is marked as crashed and should be repaired.
Does anybody know how I can fix this problem?

visible table does not exist in phpmyadmin

In mysqlworkbench, I created a view, committed it to the database, but I no longer needed it.
As such, I deleted the view in mysql workbench and then updated the database.
I thought all was fine, however in phpmyadmin, it says that the table still exists. What's more, it is constantly in use.
I tried to drop the table within phpmyadmin, however when I try to drop the table, it provides an error message saying:
1051 - Unknown table ... indicating to me that the table is not there.
but it still remains showing in the database, and under collation, it says that the table is 'in use'.
Any advice here?
Problem solved.
It appears as though you cannot delete a view from the database by normal means. The following solved the problem for me.
DROP VIEW IF EXISTS viewName;

#1054 - Unknown column 'tidbitz' in 'field list'

Via phpmyadmin I dropped the column 'tidbitz' from a table.
Now any time I try to write to that table I get this error. The column is gone and it's not included in any of the queries that I am running. I know the syntax is correct for my queries. I can't even edit data using phpmyadmin, I still get this error.
I have tried: restarting the mysql server, restarting apache, defragmenting and optimizing the table...
Why is this ghost column sticking around?
Just encountered the same problem. In my case it was caused by an insert trigger that was running a query which was using the no-longer-existing column.
I ended up fixing my problem by creating another identical table, writing all of the data from table one to table two, dropping table one, and renaming table two to table one.
So, the problem is fixed, but I'm still curious to know if anyone has encountered this before and what the root cause is.
Thanks!