Could not open a connection to SQL Server

General discussion of Mantis.

Moderators: Developer, Contributor

Post Reply
sprisoner
Posts: 2
Joined: Jul 04, 2017 9:11 am

Could not open a connection to SQL Server

Post by sprisoner » Jul 04, 2017 9:31 am

I am trying to install Mantis 2.5.1 with PHP 7.0.15 and MS SQL Server 2012. The database is already created and user has db owner permission. Pre-installation check has no errors, but when I try to install database, I get an error as:

"SQLState: 08001 Error Code: 67 Message: [Microsoft][ODBC Driver 11 for SQL Server]Named Pipes Provider: Could not open a connection to SQL Server [67]. ....A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. ..."

I have checked the following already:
  • Named pipes is already enabled on sql server.
  • I have copied php_sqlsrv_7_nts_x64.dll and php_pdo_sqlsrv_7_nts_x64.dll to php extension directory, and enabled them as extensions in PHP manager in IIS 7.
  • Connection to sql server is possible with same credentials (tested using conn.udl)
Settings in config_defaults_inc.php
$g_hostname = 'Driver={SQL Server};SERVER=server;DATABASE=dbname;UID=username;PWD=password;';
$g_db_username = 'username';
$g_db_password = 'password';
$g_db_type = 'odbc_mssql';

What could I be missing? Pls help.

atrol
Site Admin
Posts: 7677
Joined: Mar 26, 2008 4:37 pm
Location: Germany

Re: Could not open a connection to SQL Server

Post by atrol » Jul 04, 2017 2:36 pm

I can't help that much as I don't use SQL Server.
I am wondering that you have set database name, user and password in $g_host.
I would have expect that you have to set at least also $g_database_name = 'dbname';
Please use Search before posting and read the Manual

sprisoner
Posts: 2
Joined: Jul 04, 2017 9:11 am

Re: Could not open a connection to SQL Server

Post by sprisoner » Jul 05, 2017 12:24 am

Thanks. I set $g_database_name as well, and I still get the same error.

obmsch
Posts: 14
Joined: Mar 26, 2013 5:19 pm

Re: Could not open a connection to SQL Server

Post by obmsch » Jul 06, 2017 7:52 am

This is from my working config_inc.php:

# SQL Server 2012 Express/win7-32/IIS7/PHP7.1.6/ODBC-Driver 11/SQL-Driver 4.2
# $g_hostname = 'localhost\SQLEXPRESS';
# SQL Server 2016 Express/win10-64/IIS10/PHP7.1.6/ODBC-Driver 13/SQL-Driver 4.3
$g_hostname = 'MS-2\SQLEXPRESS';
$g_db_type = 'mssqlnative';
$g_database_name = 'MantisBT';
$g_db_username = '???';
$g_db_password = '???';

Can you login with your credentials using SSMS?

Hope that helps,
Martin

csharon
Posts: 8
Joined: Jul 20, 2017 12:21 pm

Re: Could not open a connection to SQL Server

Post by csharon » Jul 25, 2017 2:43 pm

Also while windows 2012 sql express is good. You will have much better luck with MYSQL.

Look up MySQL installer community. There will be a latest download. It has all the functionality of 2012 express plus some without the limitations. You will also have a bit more of a tool set for it.

While this is a personal opinion, i have run into far more issues with SQL Express. It is much more user friendly to for these kind of issues. The latter is you need to change your host to "localhost" the machine name or if you have the IP of your machine set to a specific IP, mark this as your current IP "xxx.xxx.xxx.xxx" sometimes Express can be finiky on this. Also verify your port is open for connection by using telnet for the port connection.

If it closes out you may need to adjust your windows firewall (even being localhost) or your SQL instance may not be listening, which could be services that need to be turned to automatic or failing on delayed start.

Post Reply