I have Centos7 installation with nginx/php5.6. MS SQL 2008 R2 is working on another server.
MSSQL definitely has allowed tcp connection, custom (non domain) user, firewall disabled, and I can connect to it using HeidiSQL and that setting from another Windows machine.
I can telnet to MSSQL from Centos (and I see Log error "Length specified in network packet payload did not match number of bytes read; the connection has been closed. Please contact the vendor of the client library." with centos ip address in MSSQL logs, so no errors here).
I couldn't connect to mssql from centos using php_mssql or sqlcmd;
During sqlcmd:
Microsoft (R) SQL Server Command Line Tool
Version 13.1.0007.0 Linux
[root#***]# /opt/mssql-tools/bin/sqlcmd -S *** -U ***
Password:
Sqlcmd: Error: Microsoft ODBC Driver 13 for SQL Server : Login timeout expired.
Sqlcmd: Error: Microsoft ODBC Driver 13 for SQL Server : TCP Provider: Timeout error [258]. .
Sqlcmd: Error: Microsoft ODBC Driver 13 for SQL Server : Unable to complete login process due to delay in prelogin response.
During php interactive:
php > mssql_connect('***:***', '***','***');
PHP Warning: mssql_connect(): Unable to connect to server: *** in php shell code on line 1
I also tried tsql/freetds:
/etc/freetds.conf has section
[myserver]
host = ***
port = ***
client charset = UTF-8
tds version = 8.0 //also tried 7
[root#*]# tsql -S myserver -U ***
Password:
locale is "en_US.UTF-8"
locale charset is "UTF-8"
using default charset "UTF-8"
5 //begins to count, i could't understand what does it mean
Also tried to clean it all and install php7.0 with sqlsrv extension - the same problem;
There are some network strange - Centos serv and MSSQL are in different networks, I couldnt ping mssql from that server, but can telnet, i'm using ip, not the host name during connection attempts, so don't think it's a big deal.
Now I am out of ideas where to dig, any suggestions, please?
It was caused by misconfiguration in the network, I don't understand exactly how it is possible - to make telnet connection, but fail to connect normally, but our IT guys repaired this problem in less then half an hour.
Related
I have a problem to connect using PHP 7.0 and Interbase to a remote Firebird server.
Server: Debian 6, Firebird 2.5.
Client: Centos 7, Apache/2.4.6 (CentOS) PHP/7.0.27
Interbase Extension
Firebird/InterBase Support dynamic
Compile-time Client Library Version Firebird API version 25
Run-time Client Library Version LI-V6.3.7.27050 Firebird 2.5
Error:
"Unable to complete network request to host "192.168.1.11". Failed to establish a connection."
$hostFirebird = "192.168.1.11:/usr/data/pcondominio.fdb";
$userFirebird = "sysdba";
$passFirebird = "masterkey";
$connFirebird = ibase_connect( $hostFirebird, $userFirebird, $passFirebird, 'ISO8859_1', '100', '1' ) or die( ibase_errmsg() );
Using ISQL-FB, I can connect normal in the same machine of Apache.
I just installed the tcpdump and run the command: tcpdump -i ens192 dst 192.168.1.11 and nothing appears when I run the PHO script, just the error on php: Unable to complete network request to host "192.168.1.11". Failed to establish a connection.
Running any command or connection in ISQL show: listening on ens192, link-type EN10MB (Ethernet), capture size 262144 bytes 03:04:55.513299 IP 192.168.1.9.36274 > 192.168.1.11.gds_db: Flags [P.], seq 579467323:579467335, ack 779311378, win 691, options [nop,nop,TS val 19068358 ecr 197113773], length 12
Looks like the Apache/PHP don't even try to connect.
I have no clue about what's happening.
This may be a duplicate question, however I searched internet for a while, and still couldn't find the solution.
I installed xampp on windows 7. The mysql is running on a random port. However, I can't access mysql from command line. I keep getting this error message:
ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost'
(10061 "Unknown error").
I enabled mysql for windows services as administrator, and opened the port that the mysql is using through windows firewall settings. But the problem is still not fixed, and I still can not see the port from http://canyouseeme.org/.
Open a command line with administrative privileges. Type the command below.
netstat -a -p tcp | findstr ":138"
Give it the port number that your sql is using instead of ":138" in the above example. Check if the output contains 0.0.0.0 as the IP or not. If it contains your local area network IP then use that IP to connect. Perhaps MySQL is not using all IPs to listen for connections.
maybe your mysql service is not running.
my solution:
open the run and type 'services.msc'
find the mysql count that you build(note:not the mysql, is the mysql count that you build yourself),then run this service.
Find your Path that you are install xampp server on and open CMD Write that
"C:\xampp\mysql\bin\mysqld"
click Enter and Close , reopen CMd and write
mysql -u root
video
I'm using Windows 7, 64 bits, and PHP 5.3.5.
memcache is showing as this in phpinfo:
Active persistent connections: 0
Version: 2.2.5
Revision: $Revision: 1.114 $
And I'm also getting a connection error Notice: Memcache::get() [memcache.get]: Server localhost (tcp 11211) failed
This is what I did:
1) I installed and ran the 64 bit memcached service: http://s3.amazonaws.com/downloads.northscale.com/memcached-win64-1.4.4-14.zip.
2) I copied php_memcache.dll (https://thinkam.googlecode.com/files/php_memcache-cvs-20090703-5.3-VC6-x86.zip) into php/ext.
3) I added extension = php_memcache.dll in php.ini.
4) I restarted XAMPP.
What could I be missing?
* Update *
Memcache seems to be listening now on port 11211, but now from my application I get the following error:
Notice: Memcache::get() [memcache.get]: Server 127.0.0.1 (tcp 11211)
failed with: 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.
(10060)
You must run memcached server in Windows Control Panel->Administration->Services.
Run path/memcache.exe -d start and make sure memcache is started
As #Gigala say in comments you can get another php_memchace.dll for different php versions from here http://windows.php.net/downloads/pecl/releases/memcache/3.0.8
Download the extension for your php version following this example:
php_memcache-3.0.8-5.3-nts-vc9-x86.zip as "5.3" must be your php version
This works for me
I'm attempting to connect to a SQL Azure database via PHP running on an Ubuntu 11.04 server.
The server is running PHP Version => 5.3.5-1ubuntu7.11.
I've installed freetds-bin, freetds-common, tdsodbc, odbcinst, php5-odbc and unixodbc using apt-get install multiple times. I attempted to compile FreeTDS with SSL support, but am not sure that was successful.
At this point, I receive an error "08S01 - Communication link failure" when attempting to connect using the isql tool. A Microsoft article explains the error as "The communication link between the driver and the data source to which the driver was attempting to connect failed before the SQLDriverConnect function completed processing." Some research on that specifically points to lack of SSL support in FreeTDS, but I'm unclear how to verify that has been enabled.
I will using either PHP Data Objects or mssql_* functions to connect to the SQL Azure database. I'm less familiar with PDO, but it seems that PDO does not necessarily use ODBC? I'm quite unclear on that, and I suspect it's leading me to troubleshoot problems seen by isql that are unrelated to the problems I'm seeing in PHP. Do connectivity problems with the isql tool relate to connectivity problems in either PDO or mssql_* functions in PHP?
My latest attempt, using PDO, is:
<?php
$c = new PDO("odbc:Driver=FreeTDS;Port=1433;Server=sssssssssss.database.windows.net;Database=db_xxxxx_xxx_xxx;UID=db_xxxxx_xxx_xxx_ExternalWriter;PWD=ppppppppp");
?>
This code generates the following errors in my Apache log file:
[Tue Dec 24 13:23:10 2013] [error] [client 10.1.1.11] PHP Fatal error:
Uncaught exception 'PDOException' with message 'SQLSTATE[08S01]
SQLDriverConnect: 20004 [unixODBC][FreeTDS][SQL Server]Read from the
server failed' in /var/www/test/pdo.php:3\nStack trace:\n#0
/var/www/test/pdo.php(3): PDO->__construct('odbc:Driver=Fre...')\n#1
{main}\n thrown in /var/www/test/pdo.php on line 3
My /etc/freetds/freetds.conf:
[global]
# TDS protocol version
tds version = 9.1
# Whether to write a TDSDUMP file for diagnostic purposes
# (setting this to /tmp is insecure on a multi-user system)
dump file = /tmp/freetds.log
debug flags = 0xffff
# Command and connection timeouts
; timeout = 10
; connect timeout = 10
# If you get out-of-memory errors, it may mean that your client
# is trying to allocate a huge buffer for a TEXT field.
# Try setting 'text size' to a more reasonable limit
text size = 64512
# A typical Microsoft server
[FreeTDS]
host = ssssssssss.database.windows.net
port = 1433
tds version = 9.1
client charset = UTF-8
/etc/odbc.ini:
[TS]
Description = "test"
Driver = FreeTDS
Server = sssssssssssss.database.windows.net
Port = 1433
Database = db_xxxxxxx_xxx_xxx
/etc/odbcinst.ini
[FreeTDS]
Description = tdsodbc
Driver = /usr/lib/odbc/libtdsodbc.so
Any help on this mess would be very appreciated. I'm clearly lost at this point. Thanks!
I've not tried it with Azure specifically, but on the local SQL Server machines we have here I found the php5-sybase module with PDO to be massively easier to live with than freetds:
apt-get install php5-sybase
<?php
$dsn = 'dblib:dbname=TestDB;host=sqlserver;charset=UTF-8';
$dbh = new PDO($dsn, 'username', 'password');
Also, when troubleshooting issues, I find looking at Wireshark traces of the DB traffic to be enlightening, as there are often very helpful messages emitted by SQL server that don't make it out in the PDO error.
I'm trying to connect to microsoft SQL server 2008 my application is running on a linux server and I have the dblib pdo driver installed. I used port forwarding to connect thru port 1433. I keep getting this message:
SQLSTATE[01002] Adaptive Server connection failed (severity 9);
PHP:
$connect = new PDO('dblib:host=ipaddres:1433;dbname=namedb','username','password');
I suggest to test DB connectivity w/ tsql in this way :
tsql -H server_address -p 1433 -U user -P pass -D dbname
in my case I found that simply "Reason: The password of the account has expired"
PDO gave me a strange error while tsql gave me the right error.
I got the same problem when rewriting a script from mssql_ functions to pdo.
I noticed that the old code did not have a mssql_select_db, but i used dbname in pdo.
When i removed the dbname parameter the connect worked.