Mysql ошибка 1146 doesn t exist

I am using windows XP. I am creating a table in phpMyAdmin using its built-in create table feature,
my database name is ddd.

It generates the following code:

CREATE TABLE  `ddd`.`mwrevision` (

`asd` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`sddd` INT NOT NULL
) ENGINE = INNODB;

and the following error shows up:

MySQL said:     
#1146 - Table 'ddd.mwrevision' doesn't exist 

What might be the problem?

mins's user avatar

mins

6,28612 gold badges55 silver badges75 bronze badges

asked Jun 14, 2011 at 10:29

Shaheer's user avatar

9

I also had same problem in past. All had happend after moving database files to new location and after updating mysql server. All tables with InnoDB engine disappeared from my database. I was trying to recreate them, but mysql told me 1146: Table 'xxx' doesn't exist all the time until I had recreated my database and restarted mysql service.

I think there’s a need to read about InnoDB table binaries.

Rafael Barros's user avatar

answered Dec 7, 2011 at 4:43

sempasha's user avatar

sempashasempasha

6235 silver badges18 bronze badges

2

I had the same problem and can’t get a good tip for this over the web, so I shared this for you and for all who needs.

In my situation I copy a database (all files: frm, myd) to the data folder in MySQL data folder (using Wamp at home). All thing was OK until I want to create a table and have the error #1146 Table '...' doesn't exist!.

I use Wamp 2.1 with MySQL version 5.5.16.

My solution:

  1. Export the database to file;

  2. verify if exported file is really OK!!;

  3. drop the database where I have issues;

  4. create a new database with the same name that the last;

  5. import the file to the database.

FOR ME IS PROBLEM SOLVED. Now I can create tables again without errors.

Rafael Barros's user avatar

answered Jan 24, 2012 at 6:30

carlos's user avatar

carloscarlos

1111 silver badge2 bronze badges

1

Restarting MySQL works fine for me.

answered Nov 2, 2014 at 18:24

Muhammad Usman's user avatar

Muhammad UsmanMuhammad Usman

10.3k22 gold badges72 silver badges107 bronze badges

0

In my case I ran this command even if the table wasn’t visible in PhpMyAdmin :

DROP TABLE mytable

then

CREATE TABLE....

Worked for me !

answered May 21, 2015 at 9:22

Jim 007's user avatar

Jim 007Jim 007

3101 gold badge3 silver badges8 bronze badges

1

Check filenames.

You might need to create a new database in phpmyadmin that matches the database you’re trying to import.

Mayur Birari's user avatar

Mayur Birari

5,8378 gold badges34 silver badges61 bronze badges

answered Nov 21, 2012 at 15:23

blarg's user avatar

blargblarg

3,75311 gold badges41 silver badges69 bronze badges

2

I had the same problem. I tried to create a table in mysql and got the same error. I restarted mysql server and ran the command and was able to create/migrate table after restating.

answered May 10, 2013 at 11:10

thekosmix's user avatar

thekosmixthekosmix

1,70520 silver badges34 bronze badges

Today i was facing same problem. I was in very difficult situation but what id did i create a table with diffrent name e.g (modulemaster was not creating then i create modulemaster1) and after creating table i just do the rename table.

answered Jun 12, 2013 at 11:57

Vipin Gurjar's user avatar

I encountered the same problem today. I was trying to create a table users, and was prompted that ERROR 1146 (42S02): Table users doesn't exist, which did not make any sense, because I was just trying to create the table!!

I then tried to drop the table by typing DROP TABLE users, knowing it would fail because it did not exist, and I got an error, saying Unknown table users. After getting this error, I tried to create the table again, and magically, it successfully created the table!

My intuition is that I probably created this table before and it was not completely cleared somehow. By explicitly saying DROP TABLE I managed to reset the internal state somehow? But that is just my guess.

In short, try DROP whatever table you are creating, and CREATE it again.

answered Apr 6, 2015 at 17:51

Xin's user avatar

XinXin

4,3425 gold badges19 silver badges15 bronze badges

As pprakash mentions above, copying the table.frm files AND the ibdata1 file was what worked for me.

In short:

  1. Shut your DB explorer client (e.g. Workbench).
  2. Stop the MySQL service (Windows host).
  3. Make a safe copy of virtually everything!
  4. Save a copy of the table file(s) (eg mytable.frm) to the schema data folder (e.g. MySQL Server/data/{yourschema}).
  5. Save a copy of the ibdata1 file to the data folder (i.e., MySQL Server/data).
  6. Restart the MySQL service.
  7. Check that the tables are now accessible, queryable, etc. in your DB explorer client.

After that, all was well. (Don’t forget to backup if you have success!)

Community's user avatar

answered Aug 17, 2016 at 23:46

SteveCinq's user avatar

SteveCinqSteveCinq

1,9001 gold badge16 silver badges22 bronze badges

Column names must be unique in the table. You cannot have two columns named asd in the same table.

answered Jun 14, 2011 at 10:32

Oswald's user avatar

OswaldOswald

31.1k3 gold badges43 silver badges68 bronze badges

8

run from CMD & %path%=set to mysql/bin

mysql_upgrade -u user -ppassword

answered Jun 14, 2011 at 11:04

Ravi Parekh's user avatar

Ravi ParekhRavi Parekh

5,1189 gold badges45 silver badges58 bronze badges

2

Recently I had same problem, but on Linux Server. Database was crashed, and I recovered it from backup, based on simply copying /var/lib/mysql/* (analog mysql DATA folder in wamp). After recovery I had to create new table and got mysql error #1146. I tried to restart mysql, and it said it could not start. I checked mysql logs, and found that mysql simply had no access rigths to its DB files. I checked owner info of /var/lib/mysql/*, and got 'myuser:myuser' (myuser is me). But it should be 'mysql:adm' (so is own developer machine), so I changed owner to ‘mysql:adm’. And after this mysql started normally, and I could create tables, or do any other operations.

So after moving database files or restoring from backups check access rigths for mysql.

Hope this helps…

thvwns's user avatar

thvwns

3,5483 gold badges41 silver badges57 bronze badges

answered Aug 23, 2013 at 8:32

vlad's user avatar

The reason I was facing this was because I had two «models.py» files which contained slightly different fields.
I resolved it by:

  1. deleting one of the models.py files
  2. correcting references to the deleted file
  3. then running manage.py syncdb

answered Nov 11, 2013 at 7:02

Amey's user avatar

I got this issue after copying mytable.idb table file from another location. To fix this problem I did the following:

ALTER TABLE mydatabase.mytable DISCARD TABLESPACE;

Copy mytable.idb

ALTER TABLE mydatabase.mytable IMPORT TABLESPACE;

Restart MySql

answered Apr 13, 2014 at 20:34

l0pan's user avatar

l0panl0pan

4667 silver badges11 bronze badges

1

I had the same issue. It happened after windows start up error, it seems some files got corrupted due to this. I did import the DB again from the saved script and it works fine.

answered Oct 31, 2014 at 22:51

Ayman Al-Absi's user avatar

I had this problem because of a trigger not working..Worked after I deleted the trigger.

answered Aug 2, 2016 at 12:21

DauleDK's user avatar

DauleDKDauleDK

3,20311 gold badges54 silver badges96 bronze badges

In my case, MySQL’s parameter; lower_case_table_names was configured = 0.

It causes queries related with using upper cases will not work.

answered Aug 9, 2017 at 6:25

hiropon's user avatar

hiroponhiropon

1,6552 gold badges18 silver badges41 bronze badges

For me it was a table name upper/lower case issue. I had to make sure that table case name matched in a delete query, table notifications was not the same as Notifications. I fixed it by matching table name case with query and what MySQLWorkbench reported.

What is wierd is that this error showed up in a worked sql statement. Don’t know what caused this case sensitivity. Perhaps an auto AWS RDS update.

answered Mar 16, 2018 at 15:43

Kahitarich's user avatar

KahitarichKahitarich

3852 silver badges7 bronze badges

if you are modifying mysql bin->data dir’s and after that, your database import will not works

so you need to close wamp and after that start wamp

now database import will work fine

answered Jan 15, 2021 at 19:03

Hassan Saeed's user avatar

Hassan SaeedHassan Saeed

6,2461 gold badge37 silver badges37 bronze badges

Make sure you do not have a trigger that is trying to do something with the table mentioned in the error. I was receiving Error Code: 1146. Table 'exampledb.sys_diagnotics' doesn't exist on insert queries to another table in my production database. I exported the table schemas of my production database then searched for instances of exampledb.sys_diagnotics the schema SQL and found a debugging insert statement I had added to a table trigger in my development environment but this debug statement had been copied to production. The exampledb.sys_diagnotics table was not present on my production database. The error was resolved by removing the debug statement in my table trigger.

answered May 4, 2022 at 19:33

w. Patrick Gale's user avatar

In our role as Support Engineers for web hosts, we manage servers with various services such as web, database, mail, control panels, FTP, etc.

MySQL is the most commonly used database server in Linux hosting and handling the databases and resolving the errors associated with it, is a common task that we perform.

A commonly noticed error in MySQL server is ‘1146 table doesn’t exist’. Today we’ll see what causes this ‘1146 table doesn’t exist’ error in MySQL and how to fix it.

Error : Table ‘mysql.innodb_index_stats’ doesn’t exist
status : Operation failed

What causes MySQL ‘1146 table doesn’t exist’ error

MySQL table errors happen due to many reasons, the major ones we’ve come across include:

  1. InnoDB crash – When the InnoDB server crash due to any process load or user abuse, or if the server was not restarted properly, it can get corrupt and cause table errors to show up.
  2. Missing ibdata file in the MySQL datadir – InnoDB has a data dictionary – the ibdata file and log files, which are crucial for InnoDB to function. If during migrations or restorations, these files go missing, it can prevent InnoDB tables from functioning right.
  3. Improperly placed .frm files – In InnoDB, tables have ‘.frm’ files that define the table format. If these files get deleted or were missed to copy over to the proper database directory, then the tables can show errors.
  4. Incorrect permissions and ownership of MySQL datadir – MySQL has a data directory, usually ‘/var/lib/mysql’ that stores the databases. If the permission and ownership of this directory is not adequate for MySQL to access it, errors would occur.
  5. Corrupt tables or improper table names – If the database tables got corrupt due to improper server shut down or incomplete queries, or if the table name format is not correct, the ‘1146 table doesn’t exist’ error may show up.

[ You don’t have to lose your sleep over server errors. Our expert server support specialists monitor & maintain your servers 24/7/365 and keep them rock solid. ]

How to fix MySQL ‘1146 table doesn’t exist’ error

Inorder to fix the error ‘1146 table doesn’t exist’, we adopt different techniques, after analyzing the root cause of the error.

  1. Restart MySQL server – If the error has happened due to improper server shut down or MySQL service related errors, we restart the service and check if it fixes the issue. If the service doesn’t start properly, we further investigate and fix the error.
  2. Repair the tables – MySQL has tools such as ‘myisamchk’ to repair corrupt databases and tables.  
  3. Backup restore – Restoring database backups is the final resort to get the tables back to working condition. We always configure and maintain the backups in our customers’ servers up to date, inorder to ensure that there is no data loss or down time due to unexpected crashes or errors.
  4. Copy ibdata file – If the ‘ibdata’ file is missing, we copy it from the backup and restore it to the data directory for MySQL, after discarding the tablespace to avoid any corruptions or errors.
  5. InnoDB crash recovery – In case where the backup is incomplete or ibdata file is also corrupt, we’ve still been able to recover the tables via our expert crash recovery methods. Read the post ‘Database crash rescue‘ to know more.

[ Use your time to build your business. We’ll take care of your servers. Hire Our server experts to resolve and prevent server issues. ]

At Bobcares, our 24/7 Web Support Specialists constantly monitor all the services in the server and proactively audit the server for any errors or corruption in them.

With our systematic debugging approach for service or other software errors, we have been able to provide an exciting support experience to the customers.

If you would like to know how to avoid downtime for your customers due to errors or other service failures, we would be happy to talk to you.

var google_conversion_label = «owonCMyG5nEQ0aD71QM»;

Summary: This article provides the user with a comprehensive solution to a query like “MySQL error 1146 table does not exist” using manual and professional (MySQL Database Recovery) methods. Follow each of the steps discussed here to resolve MySQL ‘1146 The table does not exist errors in your SQL Server. Download Now   Purchase Now

MySQL database is a relational database system that contains tables, these tables are formally described and they contain data within them. The data could be accessed and modified in various ways and there is no need for changing the order of tables for it. Pretty cool, Isn’t it? But sometimes corruption or mishandling of the data can lead us to errors. Error 1146 in MySQL Table doesn’t exist is also one of those common errors which can take place during MySQL handling.

So, in this handout, I’ll elaborate MySQL Error 1146, the reason behind this error and how to resolve Bug? #1146 – Table ‘xxx.xxxxx’ doesn’t exist. So without wasting time, let’s get started.

Why Error 1146 in MySQL Takes Place?

There are multiple reasons and catalyst to this error. Some of the causes to error 1146 are stated below:

  • InnoDB crash and missing data files

As we all know that InnoDB is the transaction-safe (ACID compliant) storage engine for MySQL database, it offers multiple capabilities like Rollback, Commit and crash recovery for data of MySQL database. The InnoDB is also prone to corruption, so if it is not handled correctly there is a chance of crash of InnoDB. InnoDB is functional because of ibdata file and log file. It acts as a data dictionary to it. If by any reason these files go missing, there will be no chance of working InnoDB and MySQL will show you error 1146.

  • Improper directory accessing permissions

MySQL has a data storage directory where it stores all the database. Most of the time path is ‘/var/lib/mysql’. If the ownership and access permissions are not right and MySQL is not able to access this directory path then the error 1146 in MySQL will be shown.

  • Corruption in data tables

Tables of MySQL database can get corrupt due to several reasons like improper server shutdown, incomplete queries, user abuse, wrong formats, foreign key constraint error, etc. So if the table got corrupt the database can show MySQL error 1146.

  • .frm file missing 

.frm file contains the format and structure of the database. If anyhow this file is not copied to the database directory or it gets deleted then there will be an error message for error code 1146.

Methods to Fix MySQL ERROR 1146 table doesn’t exist

To fix Bug? #1146 – Table ‘xxx.xxxxx’ doesn’t exist, we can use multiple remedies and DIYs like:

Restore Backup

This is the best alternative you should use. It will surely recreate all the lost tables from the database and MySQL code 1146 will also get solved but keep in mind that there should be a backup file to restore. So always keep the habit of creating backup time to time, it’s a good practice. Also, it resolve MySQL ERROR 1146 table doesn’t exist after backup.

Restart the Server

Try to restart the server if any improper server shutdown took place. There is a chance to get it back in working condition and removing error code. So that user access MySQL without any issue

Repair Database Tables

You can repair database tables using MySQL CLI. All you need to do is to follow the stated steps:

1. Using SSH, log in to the server.

2. From the command line, execute the following command:

             mysql -u [username] -p

             Note: Replace username with your username and remove the brackets.

3. Now enter your password for the username.

4. Again enter the command:

             use [databasename];

             Note: provide the name of the database without brackets.

5. Now execute the following command:

             show tables;

6. Now repair table using following commands:

             (a) Check for tables with error:

                    check table [tablename];

             (b) Repair tables:

                    repair table [tablename];

7. Now quit using quit command.

Keep a copy of .frm file

You can keep a copy of .frm file and whenever the error 1146 arrises, you can paste the .frm file to the schema folder. It can fix error 1146.

Copy the ibdata file from backup

You should keep a copy of ibdata file as a backup so whenever the this MySQL error takes place you can paste it to the data directory of MySQL server.

Resolve MySQL ERROR 1146 table doesn’t exist using Professional Methods

If still, the error 1146 in MySQL takes place, you should go for a professional tool rather relying on the DIYs. You can use MySQL Data Recovery tool. It is the best tool to recover the corrupt tables and even fix MySQL ERROR 1146 table doesn’t exist after backup.

Watch this video tutorial for smooth use of MySQL Recovery Tool.

Conclusion

So, this is Error 1146 in MySQL ‘table doesn’t exist’. We discussed some quick remedies and DIYs to resolve this common MySQL error. It becomes really hard and disappointing when you face such errors cause these types of errors can lead you to lose all your valuable data.

Try your best and keeping the backup of data is the best precaution you can take. It will help you in such a critical situation to restore your MySQL database in the previous condition and it will also fix Bug? #1146 – Table ‘xxx.xxxxx’ doesn’t exist. So hope for the best and do it. Thanks fo reading this article. I hope you found it useful & interesting.

Related Post

The 1146 Table Doesn’t Exist is a common error faced by MySQL server admins. While there are multiple reasons behind this error, fixing it is actually easy. In this article, we explain those reasons and provide solution to fix the issue.

Why the 1146 Table Doesn’t Exist Error Occurs?

As already mentioned, there are multiple reasons behind this issue. When you come across it, you’ll get the following error message:

Code:

Error : Table ‘mysql.innodb_index_stats’ doesn’t exist
status : Operation failed

You get this error because of the following reasons:

The InnoDB has crashed

InnoDB crashing is one of the main reasons why you have corrupt tables. InnoDB can crash if the server didn’t restart as intended or there was any type of process load. User abuse is another reasons behind the InnoDB crashing.

ibdata file is missing in MySQL datadir

The InnoDB utilizes data directory to function properly. The directory consists of ibdata file, log files, among other things. If those things aren’t available on the datadir, you’re going to face this issue. Migration, upgrades, or restoration are some events during which the ibdata file goes missing.

.frm files are placed at wrong places

InnoDB uses the .frm files to define the format of the tables. If this file is not available in the right places, InnoDB will fail to determine the table format, thus leading to the issue.

MySQL datadir has incorrect permission and ownership

Just like InnoDB, MySQL has a data directory too. It located at ‘/var/lib/mysql’ and store the database files. In case the permissions and ownership of the directory are not set appropriately, you’re going to face this error.

The tables are corrupted

There are many other ways in which the tables of an MySQL database can get corrupted. If that’s the case, you’ll come across this error message.

How to Fix this Issue?

Just like there are multiple reasons behind this issue, there are multiple ways you can fix it. Try the following solutions one by one:

Restart the MySQL Server

At times, something as simple as restarting the server can solve this issue. If the server didn’t restart properly, then restarting it once again will most likely fix the issue. If the problem persists, the continue on to the next recommended solutions.

Repair the tables

If you repair the tables, the corrupted tables will get repaired as well, thus solving the issue. Use the ‘myisamchk’ tool that comes with MySQL to repair the table.

Restore the latest backup

Restoring the latest backup (the one that was created just before the error emerged) can fix the issue. If that version is working, it must have tables that aren’t corrupt. It’s recommended that you take backups regularly, or at least once a week. This would help you restore the correct version in case you fix issues like this.

Copy the ibdata file from backup

If your ibdata file is missing, you can restore that from the backup file. It should fix the issue at hand. Restore the file to the data directory after you discard the tablespace. It’d avoid any kind of corruption.

InnoDB crash recovery

You can conduct an InnoDB crash recovery if none of the aforementioned solutions work.

So that’s how you fix the MySQL ‘1146 Table Doesn’t Exist’ error. For more assistance, contact the hosting support team.

While using an older VM with CentOS7 installed, I attempted to remove the default MySQL v5.5(ish) installation and replace it with a more recent MariaDB v10.5 for a Docker experiment. While trying to line up my DB version types due to a 16-character limit for the db usernames in older versions of MySQL, I ran into: “ERROR 1146 (42S02) at line 1: Table ‘mysql.global_priv’ doesn’t exist”.

This was an odd one, as I even removed the original MySQL completely with:

(IMPORTANT: DON’T do this unless you have your existing data backed up with a mysqldump!! Read More here: https://mariadb.com/kb/en/making-backups-with-mysqldump/)

sudo service mysql stop;

sudo yum remove mysql;

Then we need to add a recent version of MariaDB that works with CentOS7:

sudo tee /etc/yum.repos.d/mariadb.repo<<EOF

[mariadb]

name = MariaDB

baseurl = http://yum.mariadb.org/10.5/centos7-amd64

gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB

gpgcheck=1

EOF

Next we update the cache after we added MariaDB to yum:

Now we install MariaDB from the repo we configured above:

sudo yum install MariaDBserver MariaDBclient

Be sure to say “yes” to the GPG key, like so:

.....

Importing GPG key 0x1BB943DB:

...

Is this ok [y/N]: y

Now we need to start the newly installed mariadb.service so we can test it out and secure the MySQL-compatible database:

sudo systemctl start mariadb

If you want mariadb.service to be started at boot, do this:

sudo systemctl enable mariadb

Now we need to make sure that we allow connection to port 3306, like so:

sudo firewallcmd addservice=mysql permanent

sudo firewallcmd reload

Everything seemed to go fine, until the next step…

sudo mysql_secure_installation

While trying to harden the MariaDB upgrade installation with, the above command, I got the following error(s):

Enable unix_socket authentication? &#91;Y/n] Y

ERROR 1146 (42S02) at line 1: Table ‘mysql.global_priv’ doesnt exist

and/or

Change the root password? &#91;Y/n] Y

ERROR 1146 (42S02) at line 1: Table ‘mysql.global_priv’ doesnt exist

I searched in the “usual places” for an obvious fix. This seemed like it might be some kind of local Linux CentOS7 user permissions issue, at first. I went of on a few side quests and peered down the rabbit hole of Linux User permissions for MySQL packages… but I stopped myself. Anytime you see an “error on line 1” it is likely due to some kind of configuration problem, otherwise a “permission denied” or “no such user” error would be more likely.

So after I got my head right, I then tried to completely uninstall all of MariaDB, just to start from scratch (IMPORTANT: DON’T do this unless you have used mysqldump for your existing data as a back up!!)

sudo systemctl stop mariadb

sudo yum remove mariadb

After removing MariaDB, completely we need to start over. Just to be sure, we can reboot with:

After going through the entire installation process for a 2nd time, just as before (minus adding the MariaDB repo since that was done once already), I ran into the exact same issue again:

Change the root password? &#91;Y/n] Y

ERROR 1146 (42S02) at line 1: Table ‘mysql.global_priv’ doesnt exist

FAIL.

After spending awhile longer trying to understand what went wrong, I attempted the following successful “fix” to the error:

And I noticed this about 30% through the mysql_upgrade process:

...........

mysql.time_zone_name OK

mysql.time_zone_transition OK

mysql.time_zone_transition_type OK

mysql.user OK

Upgrading from a version before MariaDB10.1

Phase 2/7: Installing used storage engines

Checking for tables with unknown storage engine

Phase 3/7: Fixing views

Phase 4/7: Running ‘mysql_fix_privilege_tables’

Phase 5/7: Fixing table and database names

Phase 6/7: Checking and upgrading tables

Processing databases

information_schema

...........

…. and after that: Ka-ching!

sudo mysql_secure_installation

..........

Enable unix_socket authentication? [Y/n] Y

Enabled successfully!

Reloading privilege tables..

Success!

My MySQL client tools and CLI access to the newly updated and clean installed MariaDB worked flawlessly.

I haven’t had to run the mysql_update command to solve a problem with setting MySQL/MariaDB to start & run in many years, but the error message and missing table issue was pretty obscure. Bonus tip: if you get “error access denied” during

</p>

<! /wp:paragraph >

<! wp:urvanovsyntaxhighlighter/codeblock >

<div class=«wp-block-urvanov-syntax-highlighter-code-block»><pre class=«lang:default decode:true «>sudo mysql_update

I hope this helps someone else out! Going through this fix worked well enough for me to do my Docker tests and was still faster than spinning up a shiny new VM or embarking on an entirely new Docker Stack from scratch.

  • Mysql ошибка 1045 28000
  • Mysql код ошибки 1366
  • Mysql workbench ошибка подключения к серверу
  • Mysql workbench ошибка unable to connect to localhost
  • Mysql workbench ошибка 1822