Laravel 8 - Could not find driver : Illuminate\Database\QueryException could not find driver (SQL: select * from `list`)

Stefan Izdrail

Founder & Senior Architect · 2026-06-29

Laravel Company
Title: Laravel 8 - Fixing "could not find driver" Issues with MySQL Connections for CRUD Methods Body: Many newcomers to Laravel 8 may encounter issues when working on their database-driven web applications, such as the issue of not being able to display data from a table in the form of a grid using CRUD (Create, Read, Update, Delete) methods. This error can typically be seen as: ```php Illuminate\Database\QueryException could not find driver (SQL: select * from list) ``` This error is usually caused by incorrect configuration or misconfigured database connection details in your Laravel 8 project. To fix this, you need to ensure that all relevant files are correctly configured for the MySQL database and its tables. Here's a step-by-step guide on how to repair these errors: 1. Database Configuration: Ensure that you have followed proper installation procedures and set up your MySQL database with XAMPP. Make sure that your database is connected successfully to your Laravel project. If it isn't, please check the following links for help: - [Laravel Docs on Connecting to a Database](https://laravel.com/docs/8.x/database) - [XAMPP Installation Guide](https://www.apachefriends.org/index.html) 2. Environment File Configuration: Set up your .env file with the correct database credentials and connection information, which might look like this: ```php DB_CONNECTION=mysql DB_HOST=localhost DB_PORT=3306 DB_DATABASE=people DB_USERNAME=root DB_PASSWORD= ``` 3. Controller File Configuration: Ensure that your controller file (in this case, homeController.php) is correctly set to interact with the database and return the correct data from the tables you want to display. In this example, we are using the 'list' table: ```php $tabelku = DB::table('list')->get(); return view('tabel', ['people' => $tabelku]); ``` 4. Database Tables: Ensure that your database tables are correctly created and populated with data to be displayed via the CRUD methods. In this example, we assume you have a table named 'list' with relevant columns and values. 5. Routing Configuration: Configure your web.php file such that when users visit the appropriate routes, they should see the correct view for each page. For our example, the following code snippet is used: ```php Route::get('/home/tabel', 'homeController@tabel'); ``` 6. Views/Blade Files: Ensure that your view files (in this case, tabel.blade.php) contain appropriate HTML and PHP code to display the data correctly in a structured manner. In this example, we use a table for each row in the list table, with corresponding columns: ```html @foreach($tabelku as $t) @endforeach
No Name Age Hobby
{{$t->no}} {{$t->name}} {{$t->age}} {{$t->hobby}}
``` 7. Controller and Route Configuration: To ensure that users can access the CRUD methods for the 'list' table, create appropriate routes in your web.php file as needed. For instance, you may want to have a basic page (/home) listing all records in the list table to start with: ```php Route::get('/home', function () { return view('welcome'); }); ``` Following these steps carefully and making sure that all your configuration files are set up correctly should eliminate the "could not find driver" error you encounter when trying to display CRUD methods for your tables. If the problem still persists, kindly recheck the connection settings and ensure that MySQL is running properly on your system.