Home > Back-end >  PDOException: Could not find driver (SQL: select * from `posts`)
PDOException: Could not find driver (SQL: select * from `posts`)

Time:10-27

I am working on Laravel 8 project, I ran migrations and made models, resource controller, routes and views. After running project with routing, "could not find driver" error was appeared. Can anyone help me to solve this problem?

CodePudding user response:

It seems like you have a missing dependency. run these commands

composer update
composer require doctrine/dbal

second solution: Edit your php.ini .Find and uncomment the following line (remove the ; character)

;extension=pdo_mysql.so //uncomment this line just remove ;

CodePudding user response:

Seems like your database driver is missing.

What you can do is: First install the driver

For ubuntu and mysql database.

sudo apt-get install php7.x-mysql

Minimum is php7.3 as that is the minimum requirement for laravel 8.

You also can search for other database systems. To search for available driver in your machine/server:

sudo apt-cache search drivername

Then run the command

php artisan migrate

CodePudding user response:

If your php version is correct then

Need to open php.ini file. uncomment ;extension=pdo_mysql.so

Then, restart your Apache server. For more information, please read the documentation.

  • Related