Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

tavares's avatar

Can't connect to sql server - Could not find driver

Hi people,

I'm using os x and i have installed VM with sql server, so, i'm trying connect to database with mamp, php and freetds.

For install freetds and compile php to obtain mssql.so i was guided by this link: http://pt.stackoverflow.com/questions/529/como-utilizar-o-freetds-com-mamp-no-mac-os

After that i set up the virtual box port fowarding and run the command: tsql -H 127.0.0.1 -p 2222 -U admin -P admin and this made the connection so i think this is no freetds problem.

In respect about php i was the 5.6 version and i set the php.ini that was showed in mamp phpinfo() and also put php.ini file into $PATH. In phpinfo() i have the extension mssql: https://i.stack.imgur.com/xZSUj.png

In laravel project i have this connection 'dbname' => [ 'driver' => 'sqlsrv', 'host' => env('DB_HOST', '127.0.0.1'), 'port' => env('DB_PORT', '2222'), 'database' => env('DB_DATABASE', 'dbname'), 'username' => env('DB_USERNAME', 'admin'), 'password' => env('DB_PASSWORD', 'admin'), 'charset' => 'utf8', 'prefix' => '', ],

I also verified if mamp is using the correct php version.

I don't know what i have to do more, i'm in this for days and i can't understand why this not work.

Anyone can help me? There is something that i don't have done?

SOLUTION: I have to install also the pdo_dblib extension and turn on the directive mssql.secure_connection on mssql extension and works.

Thank you.

0 likes
5 replies
SaeedPrez's avatar

Hi @tavares,

Sounds like PHP extension for MySQL is not active.. Check your php.ini file, it's called something like php_pdo_mysql... you probably just need to uncomment it.

tavares's avatar

Thank you @SaeedPrez for answer me. I don't have nothing called with this name. I'm editing the php.ini file that shows in Loaded Configuration File of phpinfo() Helps if i send you the php.ini?

SaeedPrez's avatar

Just noticed the sqlsrv driver... Isn't that Microsoft? I'm not a Mac/Linux guy so I'm not sure how that works, sorry..

tavares's avatar

I know that this is work because i already use that but i have to clean my Mac and i have to set up all again. I add the extension mssql to php.ini and it appears on phpinfo(). Thank you so much for trying to help @SaeedPrez .

SaeedPrez's avatar

@tavares Did it work? If not try the php_pdo_odbc extension, which I believe is developed by Microsoft..

Please or to participate in this conversation.