Laravel: PDO exception, cannot find driver even if driver is installed and tested

I am working on a Laravel 5.1 project that should connect to an existing MS SQL Server database. My project is currently hosted on an Ubuntu 16.04 LTS server using Apache 2.4.18. I installed the Microsoft ODBC Linux driver for SQL Server (version 13.0.0.0) on the machine and checked it manually using the sqlcmd command:

sqlcmd -S DatabaseIPAddress -U DatabaseUsername 

Everything worked fine. I can not enter the database without problems. However, when I proceed to migrate my database using php artisan, it does not work. I get an error message:

  [PDOException] could not find driver 

I have this as a setup in database.php:

 'sqlsrv' => [ 'driver' => 'sqlsrv', 'host' => env('DB_HOST', 'localhost'), 'database' => env('DB_DATABASE', 'forge'), 'username' => env('DB_USERNAME', 'forge'), 'password' => env('DB_PASSWORD', ''), 'charset' => 'utf8', 'prefix' => '', ], 

Information for entering the database is saved in the .env file, and SQL Server is installed by default:

 'default' => env('DB_CONNECTION', 'sqlsrv'), 

Any help regarding what might be happening? I read a bunch of posts on the Internet ( here and here ). People had problems with various types of databases. They had to change the configuration of their php.ini file by adding some lines about the extensions. Maybe something like that? I tried some different things in the php.ini file that I thought might work, for example:

 ; This is the extension for the Microsoft SQLSRV ODBC Driver. ; The driver seems to be located at this file path. extionsion=/opt/microsoft/msodbcsql/lib64/libmsodbcsql-13.0.so.0.0 

rebooted, tested, but to no avail. For a while I hit my head against the wall. Any help would be greatly appreciated. Thanks.

+5
source share
1 answer

Follow these steps
sudo apt-get install php5-mssql
Update /etc/freetds/freetds.conf

 [global] # TDS protocol version ; tds version = 4.2 tds version = 8.0 client charset = UTF-8` 

Add this line to php.ini

 mssql.charset = "UTF-8" 

Link: Laracast talk

+2
source

All Articles