I have this error when i try to make php artisan migrate
IlluminateDatabaseQueryException
could not find driver (SQL: select * from information_schema.tables where table_schema = lsapp and table_name = migrations and table_type = 'BASE TABLE')
at vendor/laravel/framework/src/Illuminate/Database/Connection.php:671
667| // If an exception occurs when attempting to run a query, we'll format the error
668| // message to include the bindings with SQL, which will make this exception a
669| // lot more helpful to the developer instead of just the database's errors.
670| catch (Exception $e) {
> 671| throw new QueryException(
672| $query, $this->prepareBindings($bindings), $e
673| );
674| }
675|
+34 vendor frames
35 artisan:37
IlluminateFoundationConsoleKernel::handle(Object(SymfonyComponentConsoleInputArgvInput), Object(SymfonyComponentConsoleOutputConsoleOutput))
I have already create my database on phpmyadmin. here is the configuration of my .env file
DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=lsapp
DB_USERNAME=root
DB_PASSWORD=
and here the coonfiguration of mysql in my config/database.php
'mysql' => [
'driver' => 'mysql',
'url' => env('DATABASE_URL'),
'host' => env('DB_HOST', 'localhost'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'lsapp'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', ''),
'unix_socket' => env('DB_SOCKET', ''),
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
'prefix' => '',
'prefix_indexes' => true,
'strict' => true,
'engine' => null,
'options' => extension_loaded('pdo_mysql') ? array_filter([
PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
]) : [],
]
help me solve that problem
5
Answers
You may check if
pdo_mysql
extension is activated inphp.ini
file.In your php.ini configuration file uncomment the extension, remove
;
:If you’re on Linux make it:
Then restart the server.
If this isn’t working for you, you may need to install pdo_mysql extension into your php library.
It may be that you are using two or more versions of php. So you better do:
sudo apt install php-mysql
This way you can be sure
pdo_mysql
extension is installed on each version.After this just restart apache2:
sudo systemctl restart apache2
.I had the same issue with this setup: Laravel, composer, nginx, mariadb, and php8 on Rocky Linux 8. When running
php artisan migrate
, I got the error that mysql could not find the driver. I installedphp-mysql
and then everything worked.or
then
Good luck and hope this helps.
Failing
Working
I was able to solve it by executing the following command: