English 中文(简体)
LINUX PDO_SQLSRV 找不到司机无法连接
原标题:LINUX PDO_SQLSRV Could not find driver unable to connect

Hoping you can help. I am running Linux Ubunto 22.04 with PHP8.1.

我在本页之后安装了Sqlsrv司机:。 为服务器配置PHP的微软司机:

我仍然无法找到PDO(“sqlsrv:server= server)上的驾驶错误信息。

我不得不通过下载预设的司机来安装这些司机(包罗图班编号为2204-8.1)。 我根据:php-i ́ grep 延伸_dir,将司机档案复制至/usr/lib/php/20210902。

  • extension_dir => /usr/lib/php/20210902 => /usr/lib/php/20210902

档案10-pdo.ini先前存在于/etc/php/8.1/apache2/conf.d/。

我按照延伸=php_pdo_sqlsrv_82_nts.so的指示,创建了一个新的档案文件30-pdo-sqlsrv。

我在我的php.ini档案中添加以下内容:延伸=php_sqlsrv_81_nts.so(我核实,我通过核对在phpinfo:/etc/php/8.1/apache2/php.ini的道路,编辑了正确的php.ini文件)。

我重新启用了我的服务器(代谢2 重新启用),我列出了我的PHP模块(php-m)。 清单显示,一门魔.是他人:PDO和Pdo_sqlsrv。

PHPINFO lists the following: PDO PDO support enabled PDO drivers mysql pdo_mysql PDO Driver for MySQL enabled Client API version mysqlnd 8.1.2-1ubuntu2.14 Directive Local Value Master Value pdo_mysql.default_socket /var/run/mysqld/mysqld.sock /var/run/mysqld/mysqld.sock

I can see nothing about pdo_sqlsrv

我制定了一些法典,以测试联系:

    if (!function_exists( mysqli_init ) && !extension_loaded( mysqli )) 
{
    echo  !!We don t have mysqli!!! . "<br>";
} 
else 
{
    echo  msyqli function exists. . "<br>";
}
$mysqli = null;

if (!extension_loaded( pdo )) 
{
    echo  We don t have PDO!!! . "<br>";
} 
else 
{
    echo  PDO extension loaded. . "<br>";
}



// pdo_sqlsrv pdo_sqlsrv
if (!function_exists( pdo_sqlsrv )) 
{
    echo  !!pdo_sqlsrv does not exist!!! . "<br>";
} 
else 
{
    echo  pdo_sqlsrv extension exists. . "<br>";
}
if (!extension_loaded( pdo_sqlsrv )) 
{
    echo  !!pdo_sqlsrv not loaded!!! . "<br>";
} 
else 
{
    echo  pdo_sqlsrv extension loaded. . "<br>";
}

try
{
$connection = new PDO("sqlsrv:server=$servername;Database=$database", $user, $password);


} 
catch (PDOException $e) 
{
    echo  PDO Connection failed:   . $e->getMessage(). "<br>";
}

我的《守则》产出如下:

  • msyqli function exists.
  • PDO extension loaded.
  • !!pdo_sqlsrv does not exist!!!
  • !!pdo_sqlsrv not loaded!!!
  • PDO Connection failed: could not find driver

谁能向我指出我可能已经忽略的东西? 为什么不这样做? 我把错误的树木与我所尝试的树 the起来吗?

最佳回答

我最后为平方车开了重机。

问题回答

暂无回答




相关问题
Export tables from SQL Server to be imported to Oracle 10g

I m trying to export some tables from SQL Server 2005 and then create those tables and populate them in Oracle. I have about 10 tables, varying from 4 columns up to 25. I m not using any constraints/...

SQL server: Can NT accounts be mapped to SQL server accounts

In our database we have an SQL server account that has the correct roles to access some of the databases. We are now switching to windows authentication and I was wondering if we can create a NT user ...

SQL Server 2000, ADO 2.8, VB6

How to determine if a Transaction is active i.e. before issuing Begin Transaction I want to ensure that no previous transaction are open.. the platform is VB6, MS-SQL Server 2000 and ADO 2.8

热门标签