Mantis cannot connect to SQL Server - php

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={SQLServer};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.

ensure that your instance is configured for SQL Server authentication.
If you change the auth mode, you need to restart the instance, which can be done in SSMS by right click to the instance name --> restart.

Related

laravel sql server connection not working

I'm new to the PHP framework Laravel and I wanted to connect it with my database. What I have is:
sqlsrv as default database connection
add sqlsrv configuration
Change the .env file
Added the PHP driver to connect with SQL Server
But nothing is working :( The error I get is:
SQLSTATE[08001]: [Microsoft][ODBC Driver 11 for SQL Server]Named Pipes Provider: Could not open a connection to SQL Server (2)
Anyone who knows how to solve this?
I tried MySQL and that connection worked btw ;)
In the SQL Server Configuration Manager > SQL Server Network Configuration > TCP/IP > Properties> TCP Port check if it is set to 1433. Then restart services.
If MySQL is working and not mssql, I am assuming PHP_dblib module has not been installed.
The bellow code will display installed modules.

Cannot Connect to Azure Database through ODBC Driver 11 for SQL Server and SQL Native Client

I can easily access Azure SQL database through SQL Server 2014 but
When I am trying to connect my PHP(Laravel) web application to Azure SQL Server through ODBC Driver 11 for SQL Server and also tried with SQL Native Client 11 , it is giving me different types of exceptions as given below
[Microsoft][ODBC Driver 11 for SQL Server] A transport-level error
has occurred when receiving results from the server (provider: TCP
Provider, error: 0 - The semaphore timeout period has expired.)
[Microsoft][ODBC Driver 11 for SQL Server] A transport-level error has
occurred when receiving results from the server. (Provider: TCP
Provider, error: 0 - An existing connection was forcibly closed by
the remote host.)
[Microsoft][ODBC Driver 11 for SQL
Server]System.Data.SqlClient.SqlException: Timeout expired. The
timeout period elapsed prior to completion of the operation or the
server is not responding. The statement has been terminated.
[Microsoft][ODBC Driver 11 for SQL Server] A connection attempt
failed because the connected party did not properly respond after a
period of time, or established connection failed because connected
host has failed to respond.
[Microsoft][ODBC Driver 11 for SQL Server]Named Pipes Provider: Could
not open a connection to SQL Server [53]. , SQL state 08001 in
SQLConnect
I have gone through this Technet Article and followed all the steps successfully till step 3.
But when I traceroute to the server it is giving me following result
So, the issue which I am facing is due to reason that I am getting request timeout. And I have configured server firewall and added the client ip.
I think you can reference the article A transport-level error has occurred when receiving results from the server. People got the same error.
The possible solution is
1) Check the provider of that linked server.
2) Enable "Allow inprocess" option for that particular provider to fix the issue in provider properties.
3) For 'Packet Size=xxxxx' in connection string, try to make that 'xxxxx' shorter.
4) Try to disable "IP Offloading" on the network interfaces.
5) Restart Virsual Stdio.
6) Stopped the IIS Express and rerun your application.
Hope this can be helpful.
I have a quick test leveraging odbc_connect like:
odbc_connect("Driver={SQL Server Native Client 11.0};Server=tcp:<sqlsrv_name>.database.windows.net,1433;Database=<database>;Uid=<user>#<sqlsrv_name>;Pwd=<password>;Encrypt=yes;Connection Timeout=30;", "<user>#<sqlsrv_name>", "<password>");
However I cannot reproduce your issue. Could you please create a new Azure SQL Server, and try to connect to this new one from your local script?
If you still occur this issue, there are may be something problem with your local environment. You may check your network as your logs have shown a timeout exception.
Resolved this issue.
Problem was with the plan which I selected,it wasn't sufficient for my need.
I selected plan with higher configurations and fortunately it worked.

MS SQL SERVER, PHP, PDO, ODBC: Login failed for user

I'm trying to connect using a string:
odbc:Driver={SQL Server Native Client 11.0};Server=(localdb)\v11.0;Database=test;uid=sa;password=123321;
Result: SQLSTATE[28000] SQLDriverConnect: 18456 [Microsoft][SQL Server Native Client 11.0][SQL Server]Login failed for user 'sa'.
When I try to connect using Windows ODBC Data Source Administrator the connection is successful.
What the problem might be in?
The network user 'sa' does not have permission to the Microsoft SQL Server.
The best way to provide network users access to Microsoft SQL Server is to create a Windows group (for example EGUSERS) and permit the Windows group Server Access at the Security Logins within Microsoft SQL Server.
Put all network users that need to have access to Microsoft SQL Server to the Windows group (EGUSERS).
Check if you have the right authentication mode set on the MSSQL Server:
https://msdn.microsoft.com/en-us/library/ms188670.aspx
Also you have two ways to connect to MSSQL through PHP/PDO by using the PHP_PDO_ODBC extension which uses the ODBC driver given in the connectionstring or use PHP_PDO_SQLSRV_xx_TS or PHP_PDO_SQLSRV_xx_NTS extension which you can find here (only for 32bit PHP!) https://www.microsoft.com/en-us/download/details.aspx?id=20098 or use the unofficial 64bit here http://robsphp.blogspot.nl/2012/06/unofficial-microsoft-sql-server-driver.html
connection string when using PHP_PDO_SQLSRV_xx_(N)TS extension:
$hostname='127.0.0.1';
$dbname='test';
$username='user';
$password='pw';
$dbDB = new PDO("sqlsrv:Server=$hostname;Database=$dbname", $username, $password);
connection string when using PHP_PDO_ODBC extension:
//use any of these or check exact MSSQL ODBC drivername in "ODBC Data Source Administrator"
$mssqldriver = '{SQL Server}';
$mssqldriver = '{SQL Server Native Client 11.0}';
$mssqldriver = '{ODBC Driver 11 for SQL Server}';
$hostname='127.0.0.1';
$dbname='test';
$username='user';
$password='pw';
$dbDB = new PDO("odbc:Driver=$mssqldriver;Server=$hostname;Database=$dbname", $username, $password);
When testing a simple query which returned 66 records using PHP_PDO_ODBC extension took ~500ms (for all three MSSQL ODBC drivers) but when using the 64bit(!) PHP_PDO_SQLSRV_TS it took ~5000ms. 10 times slower! Have not yet tried 32bit or the NTS variant.
My dev PC is Windows 7 SP1 using WAMPx64 PHP 5.5.12 and I used PHP_PDO_SQLSRV_55_TS

Cannot connect to SQL SERVER 2000

I am using php 5.3.1 to connect to my SQL SERVER 2000 on remote machine. I use Windows XP.
On using simple program like this:
$conn = mssql_connect("VBNET","sa","mypass") or die ( 'Can not connect to server' );
I get following error:
Warning: mssql_connect() [function.mssql-connect]: message: Login failed for user 'sa'. Reason: Not associated with a trusted SQL Server connection. (severity 14) in C:\wamp\www\Mssql\test.php on line 8
Warning: mssql_connect() [function.mssql-connect]: Unable to connect to server: VBNET in C:\wamp\www\Mssql\test.php on line 8
Can not connect to server
I enabled TCP/IP and named pipes in my SQL SERVER and restarted it. Also its Authentication is set to Mixed Mode Authentication.
I can see my server through MS SQL Server Management Studio. So what am I missing here ?
Thanks in advance.
P.S. I have another server in SQL SERVER 2008 to which I can easily connect with the same above mentioned connection string.
EDIT: According to this post, I fired sqlcmd -S np:\\VBNET\pipe\sql\query -U sa in cmd and entered the password and that worked !!! So now what could be the problem. I am at my wits end...please help !!
If you can connect using SSMS, then copy the connection exactly, i.e. make sure you specify a named instance (e.g. 'VBNET\SQLSERVER'). Open SSMS, on the server node on the left side right click and select 'Properties'.
If you have SQL 2008 running on the same machine it is most likely that SQL 2008 uses the default instance and SQL 2000 a named instance.
What also could help, i.e. make testing simpler is to create an empty UDL file (e.g. 'TEST.UDL'). An empty text file should do. Then double click on it, select the provider and play around with the settings. You can always test the connection using the 'Test connection' button. I use this trick when I have to connect from a customer PC for the first time.

php apache (xampp) odbc connection issue

When I run apache (via xampp) as a standalone server not as a service (on Windows Server 2008)
with the following connection code everything works fine (username and password removed )
$server = "WMS";
$link = odbc_connect($server,'','');
if (!$link) {
die('Something went horribly wrong while connecting to MSSQL');
}else {echo('');}
If however I change apache to run as a service in Windows the connection breaks and I get the following error message
Warning: odbc_connect() [function.odbc-connect]: SQL error: [Microsoft][ODBC Driver Manager]
Data source name not found and no default driver specified, SQL state IM002 in SQLConnect in
C:\xampp\htdocs\Dev\well.php on line 30
Something went wrong while connecting to MSSQL
Please read documentation: http://uk.php.net/manual/en/function.odbc-connect.php
$server = "WMS"; suggests that you have ODBC alias/data source configured with that name. Error message clearly says that data source with such name (WMS) is not found. On Windows 7/Vista/XP/Server you can configure them at "Start -> Administrative Tools -> Data Sources (ODBC)" -- path can be different on older OS. In any case -- look for "Microsoft ODBC Data Source Administrator".
Instead of using alias, I would recommend (the way I always connect) to use full DSN name, e.g.
// Microsoft SQL Server using the SQL Native Client 10.0 ODBC Driver - allows connection to SQL 7, 2000, 2005 and 2008
$link = odbc_connect("Driver={SQL Server Native Client 10.0};Server=$server;Database=$database;", $user, $password);
In this case everything is part of the script and no external dependencies.
BTW -- instead of using ODBC Functions, I would recommend using PDO & driver specially for MS SQL Server: PDO_SQLSRV -- http://uk.php.net/manual/en/ref.pdo-sqlsrv.php (or Microsoft SQL Server Driver for PHP if you prefer old procedural style -- http://uk.php.net/manual/en/book.sqlsrv.php )

Categories