Topic on Project:Support desk

Brianfly (talkcontribs)

We are receiving the "Cannot access the database" error. This is a new install and we were able to complete the configuration, which means it was able to connect to the SQL server and create the database, logins and security. We also checked the box to use the same account for access as was used to create the SQL DB. We are using Windows authentication, but tried SQL server authentication as well, but with the same result. We enabled PHP errors and debugging, but got no useful information other than the below. Our environment is Windows Server 2016, SQL 2016, MediaWiki LTS 1.27.3. We have installed the correct VC and MS PHP drivers for PHP, which has been proven since everything talks to the SQL server, except after configuration. Looking at previous responses, there doesn't seem to be much help with SQL server, but thought I'd post to see if anyone has had a similar issue. Relevant error and debug log lines are:

PHP error log:PHP Warning:  Declaration of DatabaseMssql::ignoreErrors(array $value = NULL) should be compatible with DatabaseBase::ignoreErrors($ignoreErrors = NULL) in \\xxx\WikiMedia\includes\db\DatabaseMssql.php on line 1413

PHP Debug log:[error] [63d39a8a9c671c22ec901aaa] /   ErrorException from line 1413 of \\xxx\WikiMedia\includes\db\DatabaseMssql.php: PHP Warning: Declaration of DatabaseMssql::ignoreErrors(array $value = NULL) should be compatible with DatabaseBase::ignoreErrors($ignoreErrors = NULL)

[connect] Failed to connect to database 0 at xxx

Brianfly (talkcontribs)

Just an update. We were able to get SQL authentication working. We also tested windows authentication using the below script, connecting with the same apppool credentials as the site and it works as well. It seems that once the configuration is done, the wiki site does not find the windows authentication username and password. Was wondering if this can be verified?

<?php 

/* Specify the server and connection string attributes. */ 

$serverName = "xxx"; 

$connectionInfo = array( "Database"=>"test_wiki"); 

/* Connect using Windows Authentication. */ 

$conn = sqlsrv_connect( $serverName, $connectionInfo); 

if( $conn === false ) 

     echo "Unable to connect.</br>"; 

     die( print_r( sqlsrv_errors(), true)); 

/* Query SQL Server for the login of the user accessing the 

database. */ 

$tsql = "SELECT CONVERT(varchar(32), SUSER_SNAME())"; 

$stmt = sqlsrv_query( $conn, $tsql); 

if( $stmt === false ) 

     echo "Error in executing query.</br>"; 

     die( print_r( sqlsrv_errors(), true)); 

/* Retrieve and display the results of the query. */ 

$row = sqlsrv_fetch_array($stmt); 

echo "User login: ".$row[0]."</br>"; 

/* Free statement and connection resources. */ 

sqlsrv_free_stmt( $stmt); 

sqlsrv_close( $conn); 

?> 

Ciencia Al Poder (talkcontribs)
Brianfly (talkcontribs)

Thank you for your input, unfortunately, the parameter is in the localsettings.php file.

# MSSQL specific settings

$wgDBWindowsAuthentication = true;

$wgDBmwschema = "xxx";

$wgDBprefix = "";

We were able to make SQL serer authentication work by changing this setting to false and have the SQL username/password in the Database settings..........Our security won't allow this though.

31.24.13.176 (talkcontribs)

After running MediaWiki 1.27.3 with SQL Server for a while without a problem I suddenly started getting the "(Cannot access the database)" error. The log showed the same error as for the OP:

Declaration of DatabaseMssql::ignoreErrors(array $value = NULL) should be compatible with DatabaseBase::ignoreErrors($ignoreErrors = NULL) in \\xxx\WikiMedia\includes\db\DatabaseMssql.php

It turned out to be damaged SQL Server ODBC driver. I repaired the ODBC driver and the problem disappeared immediately.

Ciencia Al Poder (talkcontribs)

This error is task T162781, fixed in 1.29, but I'm not sure if there would be other MSSql errors in 1.29...

2003:72:6D60:DF00:99BD:6BB4:D5F3:8EBE (talkcontribs)

Compatibility sums this up nicely: "MediaWiki is compatible with a variety of database servers. (...) Using any other database software [apart from MySQL or MariaDB] is not recommended for production use. (...) Running MediaWiki on anything other than MySQL or MariaDB is not recommended for production use at this point."

Brianfly (talkcontribs)

Thank you, everyone, for the replies. We were trying to get this up and running for our development team to try out. Being regulated/security driven with our apps we can use MS SQL or MS SQL, so there was no other option. We thought this might be useful, but unfortunately, we just cant' get it working with Windows authentication. Even tried the latest non-LTS version. We mixed different ODBC/PHP drivers and temporarily opened up all windows firewall ports between the SQL server and IIS server, but with no success. We my re-visit this in the future, or when MS SQL is "recommended". Thanks again.