1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

"could not find driver" Error with SQL Server on WSL 2 with Ubuntu 24.04

Discussão em 'Outras Linguagens' iniciado por Matheus Inacio, Outubro 17, 2024 às 12:52.

  1. I'm encountering an issue while trying to connect my Laravel application to a SQL Server database. I'm running this setup on WSL 2 with Ubuntu 24.04 and PHP 8.3.11. Here’s a detailed overview of the problem and what I've done so far:


    • Installed Microsoft ODBC Driver for Ubuntu: I followed the official instructions to install the ODBC driver for SQL Server.


    • Installed the sqlsrv and pdo_sqlsrv Extensions: I installed these extensions using the official Microsoft documentation for PHP with FPM.


    • Reviewed Laravel's config/database.php: I ensured the configurations for the SQL Server connection were correct and matched the expected parameters.


    • Updated the .env File: I modified the .env file to specify the SQL Server connection parameters.

    Despite all the above steps, when I try to run my Laravel application, I receive the could not find driver error message when trying to log in.

    Additional Information

    • I can successfully connect to the SQL Server database using DBeaver, which indicates that the database is accessible and allows remote connections.
    • I have verified that the extensions sqlsrv and pdo_sqlsrv are installed correctly, and I checked that they are listed when running php -m. Each one of the extensions has it's own .ini file, but I've also added the lines extension=pdo_sqlsrv.so and extension=sqlsrv.so into my php.ini file to ensure that the extensions would be automatically loaded anyway.

    So, with that all being said, what could be causing Laravel to not recognize the pdo_sqlsrv driver despite it being installed? Are there any additional configurations or troubleshooting steps I can take to resolve this issue?

    Continue reading...

Compartilhe esta Página