Questions tagged [mysql-error-1146]

Error 1146 - Table 'dbname.tablename' doesn't exist

You can get MySQL error 1146 when you are trying to access a table that does not exist:

SELECT * FROM non_existent_table;

Error 1146 - Table 'dbname.non_existent_table' doesn't exist

but this error can show up for any number of other reasons, eg.

mysql> SHOW TABLES;
+-----------------------+
| Tables_in_database    |
+-----------------------+
| TABLE_ONE             |
+-----------------------+
mysql> SELECT * FROM TABLE_ONE;
ERROR 1146 (42S02): Table 'database.TABLE_ONE' doesn't exist

it could be a full partition, a corrupted database that needs to be fixed, a failed copy/restore operation, some locks or wrong/corrupted permissions on the filesystem, etc.

63 questions
167
votes
9 answers

Populating a database in a Laravel migration file

I'm just learning Laravel, and have a working migration file creating a users table. I am trying to populate a user record as part of the migration: public function up() { Schema::create('users', function($table){ …
Adam Hopkinson
  • 28,281
  • 7
  • 65
  • 99
87
votes
28 answers

Mysql 1050 Error "Table already exists" when in fact, it does not

I'm adding this table: CREATE TABLE contenttype ( contenttypeid INT UNSIGNED NOT NULL AUTO_INCREMENT, class VARBINARY(50) NOT NULL, packageid INT UNSIGNED NOT NULL, canplace ENUM('0','1') NOT NULL DEFAULT '0', …
Citizen
  • 12,430
  • 26
  • 76
  • 117
34
votes
20 answers

Bug? #1146 - Table 'xxx.xxxxx' 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`…
Shaheer
  • 2,105
  • 4
  • 25
  • 39
32
votes
2 answers

In MySQL: How to pass a table name as stored procedure and/or function argument?

For instance, this does not work: DELIMITER // CREATE PROCEDURE countRows(tbl_name VARCHAR(40)) BEGIN SELECT COUNT(*) as ct FROM tbl_name; END // DELIMITER ; CALL countRows('my_table_name'); Produces: ERROR 1146 (42S02): Table…
randomx
  • 2,357
  • 1
  • 21
  • 30
23
votes
10 answers

MySQL Table does not exist error, but it does exist

Does anyone know under what conditions you can receive an 1146: Table '.' doesn't exist error when your table does, in fact, exist? I use the same code on 5 servers, only one that I recently rented is showing this error, so I…
Troy Knapp
  • 517
  • 3
  • 8
  • 17
22
votes
7 answers

Table doesn't exist after CREATE TABLE

I'm trying to import this sql in my database name symfony CREATE TABLE IF NOT EXISTS ingredient ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(255) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; and i get #1146 -…
Julien G
  • 415
  • 1
  • 5
  • 20
15
votes
6 answers

I dropped general_log table, how do I create it again?

Logging enabled I enabled logging using: SET GLOBAL log_output = 'TABLE'; SET GLOBAL general_log = 'ON'; All executed queries was logging to mysql.general_log table. It is fine. Attempt to clear the table Then the table became large and I wanted to…
mmdemirbas
  • 9,060
  • 5
  • 45
  • 53
14
votes
2 answers

restoring a MySQL database

I have created a file named ab.sql using the mysqldump utility of a database named library. It worked fine. Now i am trying to restore it using mysqlimport. My database already exists. But i want to override it. I am using the command mysqlimport…
Suman.hassan95
  • 3,895
  • 8
  • 26
  • 24
6
votes
3 answers

SQL SHOW TABLES lists a bunch of tables, but can't SELECT with them (No such table)

I have a database called apsc and if I run SHOW TABLES; on it, these are the results: mysql> show tables; +------------------------------------+ | Tables_in_apsc | +------------------------------------+ | aps_application …
Brandon
  • 16,382
  • 12
  • 55
  • 88
6
votes
3 answers

InnoDB tables exist in MySQL but says they do not exist after copying database to new server

I used mysqldump to export my database and then I imported it into MySQL on my other server. I can now see all my tables if I do "show tables" but I can't actually select from or describe any of them. ERROR 1146 (42S02): Table 'mydatabase.user'…
mrgordon
  • 130
  • 1
  • 2
  • 7
6
votes
2 answers

Django Test Failing

I am experiencing an error running django unit tests, I've not experienced this before, and have been googling it all afternoon. I am getting this error in terminal after running django manage.py test: Error: Database test_unconvention couldn't be…
Martin Ogden
  • 872
  • 4
  • 14
5
votes
3 answers

Is there a better way to assign permissions to temporary tables in MySQL?

Our users log into the production database as a fairly low-level user, with SELECT granted at the database level, and INSERT/UPDATE/DELETE granted on the specific tables they need access to. They also have permissions to create temporary tables (we…
Drarok
  • 3,612
  • 2
  • 31
  • 48
4
votes
8 answers

Magento - Base Table core_file_storage Doesn't exist

When I look in the error log for my Magento store it is full of these errors: [02-Jun-2011 13:49:12] PHP Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42S02]: Base table or view not found: 1146 Table…
a1anm
  • 1,617
  • 11
  • 45
  • 78
3
votes
2 answers

Doctrine 2 ManyToOne mapping annotations

TwitterTweets entity: /** * MyBundle\CoreBundle\Entity\TwitterTweets * * @ORM\Table(name="twitter_tweets") * @ORM\Entity */ class TwitterTweets { /** * @var TwitterUsers * * @ORM\ManyToOne(targetEntity="TwitterUsers",…
Francesco Casula
  • 26,184
  • 15
  • 132
  • 131
3
votes
1 answer

reference to temporary relation from qualification list

Consider an SQL query like this SELECT Temp.rating, Temp.avgage FROM (SELECT S.rating, AVG (S.age) AS avgage FROM Sailors S GROUP BY S.rating) AS Temp WHERE Temp.avgage = (SELECT MIN (Temp.avgage) FROM Temp) MySQL monitor gives this error: ERROR…
bfaskiplar
  • 865
  • 1
  • 7
  • 23
1
2 3 4 5