pdo exception driver not found in laravel for sqli

2019-06-16 05:29发布

问题:

when i run php artisan migrate command i got [PDOException] could not find driver .I made my default database as sqlite and checked whether there are pdo privers for sqlite using php -i command.I couldnot understand my problem.please help me.Thanks in advance.

回答1:

Your system has missing php SQLite installation.

Install it by using:

sudo apt-get install php7.0-sqlite

Then restart your apache server

sudo /opt/lampp/lampp restart


回答2:

If you are using sqlite and try to alter a table or drop a column you have to require doctrine/dbal, as suggested in the Laravel docs.

Just do a composer require doctrine/dbal and retry your migration.



回答3:

You need to install PDO on your server, or you might have to just comment out the following line in your php.ini file.

;extension=pdo_sqlite

(remove the ; character)

You should then restart your server.



回答4:

I'm using Laravel 5.3 and I had to comment out some params in .env file.

DB_CONNECTION=sqlite
# DB_HOST=127.0.0.1
# DB_PORT=3306
# DB_DATABASE=homestead
# DB_USERNAME=homestead
# DB_PASSWORD=secret