Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

After installing Laravel version 11, I encountered an error stating that the SQLite driver was missing. Upon investigation, I realized that in Laravel 11, the .env file includes SQLite as the default database driver. #50484

Closed
Ch-Kashif171 opened this issue Mar 12, 2024 · 31 comments
Assignees
Labels

Comments

@Ch-Kashif171
Copy link

Laravel Version

11

PHP Version

8.3.2

Database Driver & Version

mysql

Description

After installing Laravel version 11, I encountered an error stating that the SQLite driver was missing. Upon investigation, I realized that in Laravel 11, the .env file includes SQLite as the default database driver. However, as I only intended to use MySQL, this caused confusion initially.

Upon switching the database driver from SQLite to MySQL in the .env file, I noticed that the variables for the database username and password were commented out. This led to further confusion on my part.

I apologize for any confusion, but I'm unsure why these variables were commented out. It seems there might have been an oversight during the configuration process.

To resolve this, I've uncommented the lines for the database username and password, providing the necessary credentials for MySQL. This ensures that Laravel can connect to the MySQL database successfully.

Steps To Reproduce

Install fresh Laravel 11 using php 8.3.2 version, after finishing the installation composer gave me the sqlite driver error says

Illuminate\Database\QueryException

could not find driver (Connection: sqlite, SQL: PRAGMA foreign_keys = ON;)

at vendor\laravel\framework\src\Illuminate\Database\Connection.php:813
809▕ $this->getName(), $query, $this->prepareBindings($bindings), $e
810▕ );
811▕ }
812▕
➜ 813▕ throw new QueryException(
814▕ $this->getName(), $query, $this->prepareBindings($bindings), $e
815▕ );
816▕ }
817▕ }

1 vendor\laravel\framework\src\Illuminate\Database\Connectors\Connector.php:65
PDOException::("could not find driver")

2 vendor\laravel\framework\src\Illuminate\Database\Connectors\Connector.php:65
PDO::__construct("sqlite:C:\laragon\www\L11\database\database.sqlite", Object(SensitiveParameterValue), ])
sqlite

@nunomaduro
Copy link
Member

What command did you use to create your Laravel application?

@Ch-Kashif171
Copy link
Author

@nunomaduro
I used the below command as mentioned in Laravel documentation.
composer create-project laravel/laravel example-app

@nunomaduro
Copy link
Member

Working on the fix.

@nunomaduro nunomaduro self-assigned this Mar 12, 2024
@PAXANDDOS
Copy link

Got the same issue there!
Was using laravel/installer:v5.6.0 with the command laravel new <name> and it failed on the migration step. Options for the installer are: breeze, react, typescript,dark, PHPUnit, and no git repository.

Using:

  • Windows 11 Pro (Build 22631)
  • PHP 8.2.9 (cli)
  • Composer version 2.6.6

@driesvints driesvints added the bug label Mar 12, 2024
@nunomaduro
Copy link
Member

This is now fixed.

@satrianovember
Copy link

This is now fixed.

how to fixed?

@rostislavjadavan
Copy link

rostislavjadavan commented Mar 13, 2024

I encountered the same issue, and it was simply because the sqlite extension was missing.

Check if it is installed, for example like this:

$ php --ini | grep sqlite

/etc/php/8.2/cli/conf.d/20-pdo_sqlite.ini,
/etc/php/8.2/cli/conf.d/20-sqlite3.ini,

@saintadjie
Copy link

same here, It's happening to me

@driesvints
Copy link
Member

@satrianovember @rostislavjadavan @saintadjie which OS are you all using? And which PHP version?

@saintadjie
Copy link

@satrianovember @rostislavjadavan @saintadjie which OS are you all using? And which PHP version?

PHP 8.3.4
I am using windows 11 locally

@rostislavjadavan
Copy link

@satrianovember @rostislavjadavan @saintadjie which OS are you all using? And which PHP version?

PHP 8.2.10-2ubuntu1 (cli) (built: Sep  5 2023 14:37:47) (NTS)
Ubuntu 23.10 (Mantic Minotaur), kernel 6.5.0-25-generic

@nunomaduro
Copy link
Member

@saintadjie @rostislavjadavan What's exactly is "happening" now? Can you share screenshots of the commands and issues you are getting?

@rostislavjadavan
Copy link

@saintadjie @rostislavjadavan What's exactly is "happening" now? Can you share screenshots of the commands and issues you are getting?

I no longer have any issues. I encountered the same error that was reported earlier, but in my case, it was due to a missing SQLite extension. I resolved the issue by installing it via apt install php-sqlite3, and then I posted my solution.

Apologies if my initial post was unclear.

@fabiomota-br
Copy link

sudo apt install php8.3-sqlite3

Fix!

@radu-lefter
Copy link

I have the same issue, but on Windows. I have uncommented the "extension=sqlite3" line in the php.ini file, but the problem persists. The sqlite dlls are in the ext folder of the php installation, but when I run "php -m | findstr pdo_sqlite", nothing is returned. How do I install those drivers on Windows?

@mood48
Copy link

mood48 commented Mar 20, 2024

The easiest way is to modify the php.ini file and uncomment ;extension=pdo_sqlite. just remove ;(semi colon) and save the file.

@radu-lefter
Copy link

The easiest way is to modify the php.ini file and uncomment ;extension=pdo_sqlite. just remove ;(semi colon) and save the file.

Thank you, it worked, I was using the wrong php.ini

@ibrarofficial
Copy link

ibrarofficial commented Mar 22, 2024

I got the same error follow the below steps to fix

1 : change the default DB connection to mysql in the .env file
2: run PHP artisan migrate in command
3: change default collection from utf8mb4_0900_ai_ci to utf8mb4_unicode_ci in config/database.php file

It worked at my side

@ampats04
Copy link

Thanks for this! This worked

@aghoshsuraj555
Copy link

How to fix this in windows ?

@aghoshsuraj555
Copy link

This is now fixed.

How this is fixed could you please explain

@akhelij
Copy link

akhelij commented May 3, 2024

How can I avoid launching the migration during my first installation of laravel 11, or at least define mysql as my default database connection

@AbdullahKhalide
Copy link

I have same error but comment is not here mean your solve is it but the problem in my project what the solve

@zll600
Copy link

zll600 commented Jul 1, 2024

I use following requirements, and encountered similiar problem

  • php: 8.2
  • larvel/framework: 11.9
  • os: Archlinux

reproduce step

  1. composer create-project laravel/laravel example-app
  2. cd example-app
  3. php artisan migrate

the problem will happen

~/Code/php/example-app ❯ php artisan migrate                                                                                                                           ✘ INT

   Illuminate\Database\QueryException 

  could not find driver (Connection: sqlite, SQL: PRAGMA foreign_keys = ON;)

  at vendor/laravel/framework/src/Illuminate/Database/Connection.php:813
    809▕                     $this->getName(), $query, $this->prepareBindings($bindings), $e
    810▕                 );
    811▕             }
    812▕ 
  ➜ 813▕             throw new QueryException(
    814▕                 $this->getName(), $query, $this->prepareBindings($bindings), $e
    815▕             );
    816▕         }
    817▕     }

      +42 vendor frames 

  43  artisan:13
      Illuminate\Foundation\Application::handleCommand()

I fixed by using https://wiki.archlinux.org/title/PHP#Sqlite

@AbdullahKhalide
Copy link

I use following requirements, and encountered similiar problem

  • php: 8.2
  • larvel/framework: 11.9
  • os: Archlinux

reproduce step

  1. composer create-project laravel/laravel example-app
  2. cd example-app
  3. php artisan migrate

the problem will happen

~/Code/php/example-app ❯ php artisan migrate                                                                                                                           ✘ INT

   Illuminate\Database\QueryException 

  could not find driver (Connection: sqlite, SQL: PRAGMA foreign_keys = ON;)

  at vendor/laravel/framework/src/Illuminate/Database/Connection.php:813
    809▕                     $this->getName(), $query, $this->prepareBindings($bindings), $e
    810▕                 );
    811▕             }
    812▕ 
  ➜ 813▕             throw new QueryException(
    814▕                 $this->getName(), $query, $this->prepareBindings($bindings), $e
    815▕             );
    816▕         }
    817▕     }

      +42 vendor frames 

  43  artisan:13
      Illuminate\Foundation\Application::handleCommand()

I fixed by using https://wiki.archlinux.org/title/PHP#Sqlite

thank you dear

@munkeywolf00
Copy link

If you are having this issue, check if the PHP version you using matches the php.ini you are editing. Make a new terminal instance if you are switching from different PHP version.

@LJunnil
Copy link

LJunnil commented Aug 6, 2024

Not working

@codinginbarn
Copy link

If you are using Windows (10 in my case), have PHP installed and in your path env, it appears that you must have extension=sqlite3 uncommented in your Windows php.ini

@abdullahilashik
Copy link

It was resolved for me adding extension=pdo_sqlite in php.ini . If this line is already in your php.ini file check if there is comment added. If so remove the comment

@flpdev
Copy link

flpdev commented Oct 28, 2024

Hello guys!

I came across to the same problem. Even i switched the default database to mysql, on run php artisan comands i found this error. i tried same solutions posted before but to my surprise i found the problem on my case. I was editing the .env.example file rsrs on change the default db to mysql in my .evn production file no more error are showed.

@Menjadianjay
Copy link

i used to get the same error, and everytime i just erase ";" in front of extension=pdo_sqlite and extension=sqlite3 on file php.ini. And serve laravel project like usual.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests