Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

raflizocky's avatar

Laravel 11 - Default migrations files

When creating a new Laravel 11 project, it generates default migration files, such as users, sessions, etc. I deleted them because they were not needed and replaced them with others. I have already migrated the new migrations. However, when I try to run the app, it shows an error. What else needs to be adjusted?

error: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'example_app.sessions' doesn't exist (Connection: mysql, SQL: select * from `sessions` where `id` = zgTO54m5S7y9dqACIgY1IcMisju0YCysSKLNuRTk limit 1)

I tried to php artisan optimize:clear, but it shows error too:


  cache ................................................................ 8s FAIL

   Illuminate\Database\QueryException 

  SQLSTATE[HY000] [2002] No connection could be made because the target machine actively refused it (Connection: mysql, SQL: delete from `cache`)

  at vendor\laravel\framework\src\Illuminate\Database\Connection.php:825
    821▕                     $this->getName(), $query, $this->prepareBindings($bindings), $e
    822▕                 );
    823▕             }
    824▕ 
  ➜ 825▕             throw new QueryException(
    826▕                 $this->getName(), $query, $this->prepareBindings($bindings), $e
    827▕             );
    828▕         }
    829▕     }

  1   vendor\laravel\framework\src\Illuminate\Database\Connectors\Connector.php:67
      PDOException::("SQLSTATE[HY000] [2002] No connection could be made because the target machine actively refused it")

  2   vendor\laravel\framework\src\Illuminate\Database\Connectors\Connector.php:67
      PDO::connect("mysql:host=127.0.0.1;port=3306;dbname=example_app", "root", Object(SensitiveParameterValue), [])
0 likes
3 replies
jj15's avatar
jj15
Best Answer
Level 10

By default, Laravel 11 uses the database for session storage and caching. You must update the SESSION_DRIVER and CACHE_STORE keys in your .env file to file or another supported driver if you don't want to use the database.

raflizocky's avatar

@jj15 Hi, thanks for the help! It didn't work at first—I’m not sure why—but it worked after a few tries and restarts.

1 like
Snapey's avatar

@raflizocky do not run artisan optimize or any of the cache commands whilst you are in development as you will find things dont change when you expect them to

Please or to participate in this conversation.