Since I had some problems with my database, I tried to drop the database. When that didn't work, I removed my database folder in C:/xampp/mysql/data. I used SHOW TABLES and it said no tables in my database.
Now the problem is, first time importing my database dump file, I got the following problem:
ERROR 1050 (42S01) at line 2990: Table '`db`.`tbl`' already exists
I tried removing the table with the following query:
DROP TABLE tbl;
This gives the following error:
ERROR 1051 (42S02): Unknown table 'db.tbl'
However, I tried to create it with the following query:
CREATE TABLE tbl (id int NOT NULL PRIMARY KEY);
MySQL gives the following error:
ERROR 1813 (HY000): Tablespace for table '`db`.`tbl`' exists. Please DISCARD the tablespace before IMPORT.
I tried looking it up but I can't figure it out. Removing the .idb file causes the same problem eventually, I can't run ALTER TABLE tbl DISCARD TABLESPACE; because it'll give the error the table db.tbl doesn't exist.
Is there a way to fix this and what is the cause of it? I got these errors out of nowhere and it's frustrating
Related
There's a table in a database of mine, let's call it table_x, that used to get created and destroyed all the time. Now that's not happening, so the table should either exist or not, and actually it should not.
When I try to get a mysqldump of the database I systematically get this error:
Error: Couldn't read status information for table table_x ()
mysqldump: Couldn't execute 'show create table `table_x`': Table 'xxxxx.table_x' doesn't exist (1146)
Like mysqldump for some reason still thinks that the table exists and when it tries to dump it it triggers the error.
SHOW TABLES does NOT show the table.
However in information_schema.TABLES it's present.
I guess that's the problem, that information_schema somehow got out of sync with reality.
How do I "repair" this inconsistency?
I tried deleting the table with
DROP TABLE table_x
but unsurprisingly I get an error that the table doesn't exist.
To avoid such kind of error during drop a table it's a good habit to use IF Exist and IF NOT EXIST as:
DROP TABLE IF EXISTS table_x;
CREATE TABLE IF NOT EXIST table_x;
I've been trying hard to migrate a Wordpress project and after a thousand attempts, this is the closest I got. I notice that the tables I imported from my previous project are the ones that Wordpress can't reach. Then I thought it was a matter of adding the "56z7sj5c2a" suffix to the tables I moved. So I executed the code ALTER TABLE wp_options RENAME TO wp_56z7sj5c2a_options;, for example. It didn't work. Does anyone have any idea how I establish this link with the new tables? Below the message error after pressing the button "repair and optimize".
The wp_56z7sj5c2a_users table is okay.
Failed to optimize the wp_56z7sj5c2a_users table. Error: Table does not support optimize, doing recreate + analyze instead
The wp_56z7sj5c2a_usermeta table is okay.
Failed to optimize the wp_56z7sj5c2a_usermeta table. Error: Table does not support optimize, doing recreate + analyze instead
The wp_56z7sj5c2a_posts table is not okay. It is reporting the following error: Table 'djt443375729453.wp_56z7sj5c2a_posts' doesn't exist. WordPress will attempt to repair this table…
Failed to repair the wp_56z7sj5c2a_posts table. Error: Table 'djt443375729453.wp_56z7sj5c2a_posts' doesn't exist
The wp_56z7sj5c2a_comments table is okay.
The wp_56z7sj5c2a_links table is okay.
The wp_56z7sj5c2a_options table is not okay. It is reporting the following error: Table 'djt443375729453.wp_56z7sj5c2a_options' doesn't exist. WordPress will attempt to repair this table…
Failed to repair the wp_56z7sj5c2a_options table. Error: Table 'djt443375729453.wp_56z7sj5c2a_options' doesn't exist
The wp_56z7sj5c2a_postmeta table is not okay. It is reporting the following error: Table 'djt443375729453.wp_56z7sj5c2a_postmeta' doesn't exist. WordPress will attempt to repair this table…
Failed to repair the wp_56z7sj5c2a_postmeta table. Error: Table 'djt443375729453.wp_56z7sj5c2a_postmeta' doesn't exist
The wp_56z7sj5c2a_terms table is okay.
The wp_56z7sj5c2a_term_taxonomy table is okay.
The wp_56z7sj5c2a_term_relationships table is okay.
The wp_56z7sj5c2a_termmeta table is okay.
The wp_56z7sj5c2a_commentmeta table is okay.
I have a corrupt table in my mysql db, that I want to remove.
It is a table that I do not use anymore, so it can be removed without any problems.
I already tried to repair the table, but then I get the following:
catalog_product_flat_1 repair Error Incorrect information in file: './catalog_product_flat_1.frm'
catalog_product_flat_1 repair error Corrupt
I can also not drop the table:
DROP TABLE catalog_product_flat_1
Unknown table 'catalog_product_flat_1'
How can I remove this table?
I created a database named "Records" in MySQL within which I created a table named "old_records" having 5 columns. When I give the command:
USE Records;
SHOW TABLES;
it displays the table named "old_records" which is existing in the database, but after that when I type the command:
DESCRIBE ORDERS;
it gives the following error:
ERROR 1146 (42S02) Table 'Records.orders' doesn't exists
I am very new to MySQL and not able to understand the cause of this error, please help.
You should use
DESCRIBE old_orders;
You've already said that the orders table does not exist, you cannot DESCRIBE something which doesn't exist
I am new to MySQL, and I am having a problem where if I try to create a Table in my newly created Database "recommend", I get the following error:
ERROR 1146 (42S02): Table 'recommend.Users' doesn't exist
I checked related posts here and on the internet but nothing helped.
If I use the MySQL command line I still get the same error.
SELECT DATABASE() FROM DUAL;
+------------+
| DATABASE() |
+------------+
| recommend |
+------------+
1 row in set (0.00 sec)
but then when i run this command :
mysql> use recommend
Database changed
mysql> CREATE TABLE Users (UserName VARCHAR(20),password VARCHAR(20),PRIMARY KEY(UserName));
ERROR 1146 (42S02): Table 'recommend.Users' doesn't exist
I also tried using Navicat and still get the same error :(
I had the same problem. I actually read this thread before I got lucky with a simple solution. I attempted to drop my table and it worked, in your case your table is User:
DROP TABLE Users;
The table does not exist, so naturally MySQL complains:
Error Code: 1051. Unknown table 'Users'
But then I ran my CREATE TABLE statement again and it worked. Hopefully others can validate this works every time? A lot easier than going to an error log, especially if you are not the greatest DBA/System Admin/Hacker.
This looks like a data dictionary problem. You can get more information by checking the error log. (See the MySQL docs here).
Possibly, you have an orphaned table. If so, the solution is to create a table of the same name in a different database, then copy the .frm file to the current database. Then you can DROP the table, and a subsequent CREATE should then succeed. More details on troubleshooting this sort of problem can be found here
The Problem was...
You have a DB with "InnoDB ENGINE".......
My Solution was...
You must have a "MyISAM ENGINE",
how to change?... find on your environment may be with
# find / -name my.cnf
on LINUX, simply add the following line to
vim /etc/mysql/my.cnf
Add:
default-storage-engine= MyISAM
Then restart mysql:
service mysql restart