Topic on Project:Support desk

Jump to navigation Jump to search

A database query error has occurred

Dennis2130 (talkcontribs)

I'm installing a fresh copy of MediaWiki 1.30 on a Windows 2012 Server running MAMP Pro but using SQL Server instead of MySQL. The setup starts out very straightforward and looks like it shouldn't have any issues until disaster strikes.

I'm able to upload the files, start the install, configure the SQL Server settings, choose options etc. Eventually i get to a page that has this line:

By pressing "Continue →", you will begin the installation of MediaWiki. If you still want to make changes, press "← Back".

After clicking continue I'm met with the following wall of red text.

[W4lTcMCoAAoAACQwHOAAAAA-] /pdmu/mw-config/index.php?page=Install Wikimedia\Rdbms\DBQueryError from line 1149 of E:\PioneerData\IT\MAMP\htdocs\PDMU\includes\libs\rdbms\database\Database.php: A database query error has occurred. Did you forget to run your application's database schema updater after upgrading?

Query: CREATE TABLE [mediawiki].[externallinks] (


el_from int NOT NULL REFERENCES [mediawiki].[page](page_id) ON DELETE CASCADE,

el_to nvarchar(max) NOT NULL,

el_index nvarchar(450) NOT NULL,

el_index_60 varbinary(60) NOT NULL default ''


Function: Wikimedia\Rdbms\Database::sourceFile( E:\PioneerData\IT\MAMP\htdocs\PDMU/maintenance/mssql/tables.sql )

Error: 257 [SQLSTATE 42000][Error Code 257][Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Implicit conversion from data type varchar to varbinary is not allowed. Use the CONVERT function to run this query.


#0 E:\PioneerData\IT\MAMP\htdocs\PDMU\includes\libs\rdbms\database\Database.php(979): Wikimedia\Rdbms\Database->reportQueryError(string, integer, string, string, boolean)

#1 E:\PioneerData\IT\MAMP\htdocs\PDMU\includes\libs\rdbms\database\Database.php(3325): Wikimedia\Rdbms\Database->query(string, string)

#2 E:\PioneerData\IT\MAMP\htdocs\PDMU\includes\libs\rdbms\database\Database.php(3274): Wikimedia\Rdbms\Database->sourceStream(unknown type, NULL, NULL, string, NULL)

#3 E:\PioneerData\IT\MAMP\htdocs\PDMU\includes\installer\DatabaseInstaller.php(225): Wikimedia\Rdbms\Database->sourceFile(string)

#4 E:\PioneerData\IT\MAMP\htdocs\PDMU\includes\installer\DatabaseInstaller.php(248): DatabaseInstaller->stepApplySourceFile(string, string, boolean)

#5 E:\PioneerData\IT\MAMP\htdocs\PDMU\includes\installer\MssqlInstaller.php(635): DatabaseInstaller->createTables()

#6 E:\PioneerData\IT\MAMP\htdocs\PDMU\includes\installer\Installer.php(1554): MssqlInstaller->createTables(MssqlInstaller)

#7 E:\PioneerData\IT\MAMP\htdocs\PDMU\includes\installer\WebInstallerInstall.php(44): Installer->performInstallation(array, array)

#8 E:\PioneerData\IT\MAMP\htdocs\PDMU\includes\installer\WebInstaller.php(277): WebInstallerInstall->execute()

#9 E:\PioneerData\IT\MAMP\htdocs\PDMU\mw-config\index.php(80): WebInstaller->execute(array)

#10 E:\PioneerData\IT\MAMP\htdocs\PDMU\mw-config\index.php(39): wfInstallerMain()

#11 {main}

This particular error is pretty straight forward and by going into the tables.sql script I can fix it. After it's fixed I receive errors about the Unsigned Constraints. After fixing that I receive errors about missing tables. These errors are caused by tables being created with foreign keys pointing to tables that haven't been created yet. Again, I can fix that. I can go through the tables.sql and make that particular file work.

Once it's done I receive an error that MediaWiki Could not create a new page. It already exists.

I'm really struggling. I'm thinking that I should be able to get this installed without making changes to the tables.sql script. I'm hopeful that getting past that will take care of the remaining issues as well.

Any help would be hugely appreciated.


Dennis Edmondson

Mainframe98 (talkcontribs)

There have been quite some changes to the MediaWiki database layout recently, including MSSQL. However, since 1.30.0 is an outdated version of MediaWiki, these changes aren't available in the version you're using. Instead, download the latest version of MediaWiki (1.31.0).

Mainframe98 (talkcontribs)

I just noticed Phab:T202637 from Topic:Ujb49p5imknu2w96, which means the installation will fail on 1.31.0 as well. Presumably 1.32.0 will address these issues, but that version will not be released before November 2018.

MarkAHershberger (talkcontribs)

You're right, this should work without you modifying the files.

However, we don't really have anyone dedicated to maintaining SQL Server support. I've thought of setting up an instance on Azure so I could test this, but that would add to my already big workload.

If you can share the modifications you've made, I can help you get those incorporated into MediaWiki so that we can improve the support for MediaWiki. Please file a task on Phabricator with your changes and point me to it.

Dennis2130 (talkcontribs)


You're right in that this does happen in 1.31.0 I actually tried that one first and rolled back to 1.30 in the hopes that it would work. How far back do I need to go?


The problem is that taking care of the tables.sql script isn't enough to make it so that I can install the wiki. I'm still having the error pop up that the page already exists and I never get my LocalSettings.php file.

MarkAHershberger (talkcontribs)

@Dennis2130, tables.sql won't solve everything, right. But it is a necessary prerequisite to solving the problem.

As far as how far back you need to go, try 1.27. Anything before that is completely un-supported.