本文介绍了在Windows中使用sqlsrv数据库时Laravel迁移找不到驱动程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在项目中使用 sqlsrv数据库连接,因为我需要连接到Microsoft SQL数据库.

我已经成功安装了 sqlsrv驱动程序,因为我可以连接到数据库以检索数据.

但是当我尝试进行Laravel迁移时,它显示了一个错误:

  Illuminate \ Database \ QueryException:找不到驱动程序(SQL:从类型='U'并且名称= migrations的sysobjects中选择*) 

下面是我的.env

  DB_CONNECTION = sqlsrvDB_HOST = **********.database.windows.netDB_PORT = 1433DB_DATABASE = **************** _ 4cd1_9d18_2a7d9ddbcd13DB_USERNAME = *************** _ 4cd1_9d18_2a7d9ddbcd13_ExternalWriterDB_PASSWORD = *************** 

php.ini

  extension = php_xmlrpc.dll扩展名= php_xsl.dll扩展名= php_pdo_sqlsrv_7_nts_x64.dll扩展名= php_pdo_sqlsrv_7_nts_x86.dll扩展名= php_pdo_sqlsrv_7_ts_x64.dll扩展名= php_pdo_sqlsrv_7_ts_x86.dll扩展名= php_pdo_sqlsrv_71_nts_x64.dll扩展名= php_pdo_sqlsrv_71_nts_x86.dll扩展名= php_pdo_sqlsrv_71_ts_x64.dll扩展名= php_pdo_sqlsrv_71_ts_x86.dll扩展名= php_sqlsrv_7_nts_x64.dll扩展名= php_sqlsrv_7_nts_x86.dll扩展名= php_sqlsrv_7_ts_x64.dll扩展名= php_sqlsrv_7_ts_x86.dll扩展名= php_sqlsrv_71_nts_x64.dll扩展名= php_sqlsrv_71_nts_x86.dll扩展名= php_sqlsrv_71_ts_x64.dll扩展名= php_sqlsrv_71_ts_x86.dll 
解决方案

如何在xampp上的PHP 7.2版本中使用SQL Server DLL文件

很难找到这个解决方案.希望对您有帮助.祝一切顺利:)

I am using sqlsrv database connection in my project as I need to connect to Microsoft SQL Database.

I have successfully installed the sqlsrv driver because I can connect to the Database to retrieve data.

But when I try to do the Laravel Migration, it shows an error:

Illuminate\Database\QueryException  : could not find driver (SQL: select * from sysobjects where type = 'U' and name = migrations)

Below is my .env

DB_CONNECTION=sqlsrv
DB_HOST=**********.database.windows.net
DB_PORT=1433
DB_DATABASE=****************_4cd1_9d18_2a7d9ddbcd13
DB_USERNAME=***************_4cd1_9d18_2a7d9ddbcd13_ExternalWriter
DB_PASSWORD=***************

php.ini

extension=php_xmlrpc.dll
extension=php_xsl.dll
extension=php_pdo_sqlsrv_7_nts_x64.dll
extension=php_pdo_sqlsrv_7_nts_x86.dll
extension=php_pdo_sqlsrv_7_ts_x64.dll
extension=php_pdo_sqlsrv_7_ts_x86.dll
extension=php_pdo_sqlsrv_71_nts_x64.dll
extension=php_pdo_sqlsrv_71_nts_x86.dll
extension=php_pdo_sqlsrv_71_ts_x64.dll
extension=php_pdo_sqlsrv_71_ts_x86.dll


extension=php_sqlsrv_7_nts_x64.dll
extension=php_sqlsrv_7_nts_x86.dll
extension=php_sqlsrv_7_ts_x64.dll
extension=php_sqlsrv_7_ts_x86.dll
extension=php_sqlsrv_71_nts_x64.dll
extension=php_sqlsrv_71_nts_x86.dll
extension=php_sqlsrv_71_ts_x64.dll
extension=php_sqlsrv_71_ts_x86.dll
解决方案

How to use SQL Server DLL files with PHP 7.2 version on xampp

https://github.com/Microsoft/msphpsql/releases

To download Windows DLLs for PHP 7.1 or above from the PECL repository, please go to the SQLSRV or PDO_SQLSRV PECL page.

https://pecl.php.net/package/sqlsrv/5.6.1/windows

https://pecl.php.net/package/pdo_sqlsrv/5.6.1/windows

NOTE: Do not forget to remove 'php_' prefix when you add extension dll filename in php.ini file. eg.

extension=pdo_sqlsrv
extension=sqlsrv

Do not change actual filename which you put in /xampp/php/ext/ directory.

"7.2 Thread Safe (TS) x86" worked for me for 'sqlsrv' and 'pdo_sqlsrv' extensions.

Restart xampp or apache then you can see enabled 'pdo_sqlsrv' extension when you print phpinfo() in a test php file

It was very hard to find this solution. I hope, this will also help you. All the best :)

这篇关于在Windows中使用sqlsrv数据库时Laravel迁移找不到驱动程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-19 03:19