SQLSTATE\[42S02\] Base table or view not found - Rocketeers 8" x-data="{ menu: false, scrolled: false }" x-effect="document.body.style.overflow = menu ? 'hidden' : ''"&gt;

 On this page

 Knowledge
---------

SQLSTATE\[42S02\] Base table or view not found
==============================================

### [\#Databases](https://rocketee.rs/index.php/databases)

This MySQL error means your query references a table that does not exist in the connected database. In Laravel it almost always means migrations have not run, or you are connected to the wrong database.

 Published by Mark van Eijk on June 23, 2026 · 1 minute read

1. [About the error](#content-about-the-error)
2. [Why do I see this error](#content-why-do-i-see-this-error)
3. [Solution](#content-solution)
4. [Run your migrations](#content-run-your-migrations)
5. [Confirm you're on the right database](#content-confirm-youre-on-the-right-database)
6. [Check the model's table name](#content-check-the-models-table-name)

[\#](#content-about-the-error "Permalink")About the error
---------------------------------------------------------

In Laravel the message reads:

 ```
SQLSTATE[42S02]: Base table or view not found: 1146 Table 'my_app.users' does not exist

```

The query is valid SQL, but the table it names isn't present in the database you're connected to.

[\#](#content-why-do-i-see-this-error "Permalink")Why do I see this error
-------------------------------------------------------------------------

- Your migrations haven't run, so the table was never created.
- You're connected to the wrong database (wrong `DB_DATABASE`, or a fresh/empty database).
- The table name has a typo, or you renamed it without updating the model's `$table`.
- A migration failed halfway and the table was rolled back or never committed.

[\#](#content-solution "Permalink")Solution
-------------------------------------------

### [\#](#content-run-your-migrations "Permalink")Run your migrations

The most common fix, especially on a fresh checkout or a new environment:

 ```
php artisan migrate

```

To check what has and hasn't run:

 ```
php artisan migrate:status

```

On a development database you can rebuild everything from scratch:

 ```
php artisan migrate:fresh

```

Be careful: `migrate:fresh` **drops every table first**. Never run it against a database with data you care about.

### [\#](#content-confirm-youre-on-the-right-database "Permalink")Confirm you're on the right database

Verify your connection settings point where you think they do:

 ```
DB_DATABASE=my_app

```

Then check the table really exists there:

 ```
SHOW TABLES FROM my_app;

```

If the value changed recently, clear any cached config so Laravel reads the new one:

 ```
php artisan config:clear

```

### [\#](#content-check-the-models-table-name "Permalink")Check the model's table name

If Eloquent guesses the wrong table name, set it explicitly:

 ```
class Customer extends Model
{
    protected $table = 'customers';
}

```

See [environment variables in Laravel](/environment-variables-laravel) for how the connection is configured.

### Subscribe to our newsletter

Do you want to receive regular updates with fresh and exclusive content to learn more about web development, hosting, security and performance? Subscribe now!

  Fill in your email address to receive updates  Subscribe 

#### Related articles

[Stream MySQL backup directly to S3 bucket](https://rocketee.rs/index.php/stream-mysql-backup-s3-bucket)
--------------------------------------------------------------------------------------------------------

This MySQL error means your query references a table that does not exist in the connected database. In Laravel it almost always means migrations have not run, or you are connected to the wrong database.

[Read more →](https://rocketee.rs/index.php/stream-mysql-backup-s3-bucket)

[Export MySQL database using command line](https://rocketee.rs/index.php/export-database-mysql-command-line)
------------------------------------------------------------------------------------------------------------

This MySQL error means your query references a table that does not exist in the connected database. In Laravel it almost always means migrations have not run, or you are connected to the wrong database.

[Read more →](https://rocketee.rs/index.php/export-database-mysql-command-line)
