Reputation: 321
When I run php artisan migrate
command I get:
[PDOException] could not find driver.
I made my default database as sqlite and checked whether there are pdo drivers for sqlite using php -i
command. I could not understand my problem.
Upvotes: 31
Views: 31332
Reputation: 1212
install php extension for sqlite apt --yes install php8.2-sqlite3
(for php 8.2)
go to .env
file, set DB_CONNECTION=sqlite
and comment another options: DB_HOST
, DB_PORT
, DB_DATABASE
, DB_USERNAME
, DB_PASSWORD
and add DB_FOREIGN_KEYS=true
DB_CONNECTION=sqlite
#DB_HOST=
#DB_PORT=
#DB_DATABASE=
#DB_DATABASE=
#DB_USERNAME=
#DB_PASSWORD=
DB_FOREIGN_KEYS=true
edit php.ini
: find ;extension=pdo_sqlite
and remove ;
and save file
restart php sudo service php8.2-fpm restart
make permissions for database/database.sqlite
as 0777
run php artisan migrate
also do not make changes at config/database.php
in sqlite
section, it has to be
'database' => env('DB_DATABASE', database_path('database.sqlite')),
Upvotes: 0
Reputation: 4163
You need to install PDO on your server OR you can just uncomment the following line in your php.ini
config file.
To find the
php.ini
file, you can runphp-config
to show you where it's located.
Remove the comment character ;
from:
;extension=pdo_sqlite
to:
extension=pdo_sqlite
Finally, save the change and restart your server.
Upvotes: 18
Reputation: 95
For those using Windows and Xampp Just uncomment theses lines in php.ini :
extension=pdo_sqlite
extension=sqlite3
Upvotes: 6
Reputation: 2856
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
Upvotes: 49
Reputation: 43
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
Upvotes: -3
Reputation: 482
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.
Upvotes: 2