skip to Main Content

I’ve been building a laravel application, then xampp gave so many issues so I deleted it with the databases. Then created new empty database and tried to migrate, but it giving me this error:

SQLSTATE[42S02]: Base table or view not found: 1146 Table ‘accept.users’ doesn’t exist (SQL: select * from users where id = 1 limit 1)

  at C:UserseymenOneDriveDesktopworkwebsitesacceptvendorlaravelframeworksrcIlluminateDatabaseConnection.php:760
    756▕         // If an exception occurs when attempting to run a query, we'll format the error
    757▕         // message to include the bindings with SQL, which will make this exception a
    758▕         // lot more helpful to the developer instead of just the database's errors.
    759▕         catch (Exception $e) {
  ➜ 760▕             throw new QueryException(
    761▕                 $query, $this->prepareBindings($bindings), $e
    762▕             );
    763▕         }
    764▕     }

  i   A table was not found: You might have forgotten to run your database migrations.
      https://laravel.com/docs/master/migrations#running-migrations

  1   [internal]:0
      IlluminateFoundationApplication::IlluminateFoundation{closure}(Object(AppProvidersRouteServiceProvider))

  2   C:UserseymenOneDriveDesktopworkwebsitesacceptvendorlaravelframeworksrcIlluminateDatabaseConnection.php:414
      PDOException::("SQLSTATE[42S02]: Base table or view not found: 1146 Table 'accept.users' doesn't exist")

I’ve tried to re-install the project and after installed composer I tried to migrate and got the same error. I’ve also tried to create a temporary users table with only 1 column, but it gave me error asking about the other columns.

I literally have no idea what to do (even chatGPT freaked out).

3

Answers


  1. Chosen as BEST ANSWER

    the problem is that php artisan executes some codes in the website some why, and I have a User::all() in my code. the problem solved by commenting the web.php contents.


  2. try running php artisan migrate:fresh in case it`s development DB

    Login or Signup to reply.
  3. After creating the database, edit the .env file.

    And run php artisan migrate:fresh

    Or make sure to rename the migration files in correct order.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search