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.
Feb 15, 2025
3
Level 1
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), [])
Level 10
Please or to participate in this conversation.