[SOLVED] MySQL: ERROR 1146 table doesn't exist…although it does

Issue

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:
enter image description here

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

Solution

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.

Answered By – siride

Answer Checked By – Gilberto Lyons (BugsFixing Admin)

Leave a Reply

Your email address will not be published. Required fields are marked *