"connection rejected by remote interface" connecting to Firebird 3 with PDO - php

Try code below, but cause exception - SQLSTATE[HY000] [335544421] connection rejected by remote interface:
try {
$dbh = new PDO("firebird:dbname=localhost/3050:empty", "SYSDBA", "masterkey");
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sth = $dbh->query('SELECT idmspos, idmsqnt, cdmsval from svc$dms');
$sth->setFetchMode(PDO::FETCH_ASSOC);
while($row = $sth->fetch()) {
echo $row['idmspos']." ".$row['idmsqnt']." ".$row['cdmsval']."<br>";
}
$dbh = null;
}
catch(PDOException $e) {
$dbh = null;
echo $e->getMessage();
}
Specs:
Linux 3.2.0-4-686-pae #1 SMP Debian 3.2.65-1+deb7u1 i686 GNU/Linux
PHP 5.6
php5-interbase
Firebird 3 from official site. Server is worked, can connect to him from local and remote machine.

Find firebird.conf, uncomment (if using fbclient 2.x) and change the following parameters to disable WireCrypt and set higher priority for legacy authentication:
WireCrypt = Disabled
AuthServer = Legacy_Auth, Srp, Win_Sspi
AuthClient = Legacy_Auth, Srp, Win_Sspi

May be a bit late for the questioner but the "connection rejected by remote interface" might still be current topic as there was a change in the firebird api from debian 8 to 9/10.
The problem does also depend on which interbase/firebird-client-library to use. While in debian 8 one has libfbclient2 in Firebird API Version 2.5, starting from Debian 9 this libfbclient2 been upgraded to Firebird API 3.0. libFBclient ist the client-library to connect to Firebird / Interbase-Servers.
If, now, you have an old-versioned server, as we do, namely Interbase XE3 from year 2012, the new firebird-library in version 3.0 can not connect anymore to this old server type, while the previous library 2.5 can.
So one solution for us when migrating from Debian 8 to Debian 10 was to install the old version of libfbclient2 from debian 8 to the new Debian 10 system and then, afterwards, install the higher language clients, e.g. php7.3-interbase.
When installing the system in this manner, the php 7.3. interbase client shows no problems connecting the the old interbase server.
Here is a small instruction on how to install libfbclient2 (api version 2.5 from debian 8) to a new debian 9/10 system and to use it with php7.3:
First, uninstall all higher level language client packages, like php7.3-interbase and all firebird common/client/server-stuff.
Then download and first install via dpkg calls the old libfbclients from debian 8. They can be found hier:
https://packages.debian.org/jessie/libfbclient2
However, this package depends on the 4 following packages:
multiarch-support
libc6
firebird2.5-common
firebird2.5-common-doc
While the first two ones are in suitable version already available in Debian 10 and could be installed right from there, the latter two need to be downloaded from the debian 8 jessie - archive and need to be installed first.

You need to change the Firebird service as follows:
Install Firebird
Go search Services-> Firebird
Right click on Firebird->Properties-> LogOn-> and tick checkbox having option as "Allows services to interact with Desktop"
and then click on Restart service
You are now able to connect with firebird successfully in case of Firebird 2.1.

Related

PHP Firebird with Debian 8 - VestaCP

I want to get data from Firebird database with PHP. I have a VPS server and Operation System Debian 8 and main panel Vesta CP. My PHP version is PHP 5.
I found some information on web and I tried all of them but it's not happened. How can I get data from Firebird database with php?
http://php.net/manual/tr/ibase.installation.php
http://www.firebirdfaq.org/faq234/
i solved this problem, reinstall OS but not Debian 8 , setup Debian 9.3 and VestaCP.
So php version is 7. and on console ;
apt-get install php7.0-interbase
almost done

configure pdo_dblib - freetds already installed

I am running a Linux server that already has freetds installed, but is not configured to support dblib. Only sqlite and mysql are currently supported for PDO. MSSQL support is also enabled.
If I want to add support for dblib and enable the PDO Driver for FreeTDS/Sybase DB-lib, do I just need to run this command on the existing install:
./configure --with-pdo-dblib
If so, from which directory would I run the command?
Environment:
PHP Version 5.5.38
CENTOS 6.9
Thank you
If you have configured FreeTDS correctly, you should be able to connect like so:
$pdo = new PDO("dblib:host=mssql;dbname=$dbname", "$dbuser","$dbpwd");
If you can't, this answer gives more explicit instructions: Connect PHP to MSSQL via PDO ODBC
pdo_dblib is typically installed in most Linux distros when you install php-mssql (on CentOS and Ubuntu, for example). If the connect command isn't working, please rewrite your question to include the specific steps you have taken and the error output. Good luck!
Since writing this question, the support team at the company that is hosting this server installed the driver. I don't know exactly what steps they took to do it so I can not post a step by step answer as I would like. Closing this question.

Connect to SQL Server from CakePHP 3 on Ubuntu 12.04 LTS

My setup was working on Windows but I recently switched to Ubuntu 12.04 LTS and now it won't connect. When I load a page where I need to talk to SQL Server, I get this error:
Database driver Cake\Database\Driver\Sqlserver cannot be used due to a
missing PHP extension or unmet dependency
It is obvious that CakePHP can't find the SQL Server PDO driver.
I found many old tutorials to help me but I took the most recent (I want absolutely to be able to use PDO with my CakePHP website). This is the tutorial I followed.
Using the terminal, I can access the database with this command
sqlcmd -S my.sql.server.com -U username
What do I need to do to connect to this sql server database from my ubuntu install with CakePHP 3.x?
Update (October 17th 2016):
Microsoft recently released a preview version (on their msphpsql repo) of pdo_sqlsrv and sqlsrv for Linux. It worked successfully for me on a Ubuntu 16.04.1 LTS (Xenial Xerus) virtual machine running php7.
Original answer:
As #AD7six said:
CakePHP's sql server driver is for using PDO_SQLSRV; If you need to use ODBC, there isn't one in the core.
PDO_SQLSRV is working if you are on Windows. CakePHP has a driver that support it natively.
If you want to talk to a SQL Server Database from Linux, you have to use the ODBC driver. You can install the driver using this tutorial which helped me a lot. After that, you will be able to connect to your database using PDO (not CakePHP):
try {
$query = new PDO(
"odbc:Driver={SQL Server};Database=[Database name]; Server=[Hosame]",
"[Username]",
"[Password]");
} catch (PDOException $e) {
echo 'Connection failed: ' . $e->getMessage();
}
Thanks everybody for your help. It could be great to find/code a CakePHP 3 database driver for odbc.
The new version of CakePHP supports PDO-sqlsrv which is new the MS driver that supports PHP 7 and higher.
http://php.net/manual/en/ref.pdo-sqlsrv.php
It also allows you to connect to Azure. Example:
//Establishes the connection
$conn = new PDO( "sqlsrv:server=$serverName ; Database = $database", $uid, $pwd);

Headers and client library minor version mismatch

In PHP I'm getting the following warning whenever I try to connect to a database (via mysql_connect)
Warning: mysql_connect(): Headers and client library minor version mismatch. Headers:50162 Library:50524
In my php -i output I have the following values listed under mysqli
Client API library version => 5.5.24
Client API header version => 5.1.62
I've tried updating php5-mysql and php but I'm already at the latest version of both of them. How do I go about updating the header version so I stop seeing this warning?
EDIT
My MySQL files should all be updated to be the latest version:
$ apt-get install mysql.*5.5
. . .
mysql-client-5.5 is already the newest version.
mysql-server-core-5.5 is already the newest version.
mysql-server-5.5 is already the newest version.
mysql-testsuite-5.5 is already the newest version.
mysql-source-5.5 is already the newest version.
Removing old versions
$ apt-get remove mysql.*5.1
. . .
Package handlersocket-mysql-5.1 is not installed, so not removed
Package mysql-cluster-client-5.1 is not installed, so not removed
Package mysql-cluster-server-5.1 is not installed, so not removed
Package mysql-client-5.1 is not installed, so not removed
Package mysql-client-core-5.1 is not installed, so not removed
Package mysql-server-5.1 is not installed, so not removed
Package mysql-server-core-5.1 is not installed, so not removed
Package mysql-source-5.1 is not installed, so not removed
I am using MariaDB and have a similar problem.
From MariaDB site, it is recommended to fix it by
Switch to using the mysqlnd driver in PHP (Recommended solution).
Recompile PHP with the MariaDB client libraries.
Use your original MySQL client library with the MariaDB.
My problem was fixed by using the mysqlnd driver in Ubuntu:
sudo apt-get install php5-mysqlnd
[update: extra information] Installing this driver also resolve PDO problem that returns integer value as a string. To keep the type as integer, after installing mysqlInd, do this
$db = new PDO('mysql:host='.$host.';dbname='.$db_name, $user, $pass,
array( PDO::ATTR_PERSISTENT => true));
$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
$db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, false);
For new MySQL 5.6 family you need to install php5-mysqlnd, not php5-mysql.
Remove this version of the mysql driver
sudo apt-get remove php5-mysql
And install this instead
sudo apt-get install php5-mysqlnd
Your PHP was compiled with MySQL 5.1 but now it is linking a mysql library of 5.5.X family.
You have to upgrade PHP to a version compiled with MySQL 5.5 or revert back mysql client libraries to 5.1.x.
The same works for MySQL:
sudo apt-get install php5-mysqlnd
I've read this thread trying to find the solution for MySQL, and I've also seen ken's answer, but I ignored the solution for MariaDB, wasting a few hours that way. It wasn't clear for me that the same may apply to MySQL. This post is just to spare you the few hours I lost.
The root reason for this error is that PHP separated itself from the MySQL Client libraries some time ago. So what's happening (mainly on older compiles of linux) is that people will compile PHP against a given build of the MySQL Client (meaning the version of MySQL installed is irrelevant) and not upgrade (in CentOS this package is listed as mysqlclientXX, where XX represents the package number). This also allows the package maintainer to support lower versions of MySQL. It's a messy way to do it, but it was the only way given how PHP and MySQL use different licensing.
MySQLND solves the problem by using PHP's own native driver (the ND), which no longer relies on MySQL Client. It's also compiled for the version of PHP you're using. This is a better solution all around, if for no other reason that MySQLND is made to have PHP talk to MySQL.
If you can't install MySQLND you can actually safely ignore this error for the most part. It's just more of an FYI notice than anything. It just sounds scary.
My hosting company told me to fix this by deactivating "mysqli" and activating "nd_mysqli" in the php extensions.
The error is gone, but I don't have the knowledge to understand if this is the right method to fix this.
To compile php from source with MySQL native driver (mysqlnd),
cd /php/source/path
./configure <other-options> --with-mysql --with-mysqli --with-pdo-mysql
make clean # required if there was a previous make, which could cause various errors during make
make
make install
From /php/source/path/configure --help.
--with-mysql=DIR Include MySQL support. DIR is the MySQL base
directory, if no DIR is passed or the value is
mysqlnd the MySQL native driver will be used
--with-mysqli=FILE Include MySQLi support. FILE is the path
to mysql_config. If no value or mysqlnd is passed
as FILE, the MySQL native driver will be used
--with-pdo-mysql=DIR PDO: MySQL support. DIR is the MySQL base directory
If no value or mysqlnd is passed as DIR, the
MySQL native driver will be used
One or more PHP MySQL extensions can be included by using these options.
If a value is not passed to these options, or if the value is mysqlnd, MySQL native driver will be used.
I got same php warring in my wordpress site...
Err: Warning: mysql_connect(): Headers and client library minor version mismatch. Headers:50547 Library:50628 in /home/lhu/public_html/innovacarrentalschennai.com/wp-includes/wp-db.php on line 1515
Cause: I updated wp 4.2 to 4.5 version (PHP and MySql mismatch )
I changed wp-db.php on line 1515
$this->dbh = mysql_connect( $this->dbhost, $this->dbuser, $this->dbpassword, $new_link, $client_flags );
to
if ( WP_DEBUG ) {
$this->dbh = mysql_connect( $this->dbhost, $this->dbuser, $this->dbpassword, $new_link, $client_flags );
} else {
$this->dbh = #mysql_connect( $this->dbhost, $this->dbuser, $this->dbpassword, $new_link, $client_flags );
}
Its got without warring err on my wordpress site
If u had access cpanel or whm for domain web hosting ...
In cPanel, Go to "Softwares and services" tab, >> and then click "Select PHP Version" >> set your desired version of php...
Eg.
Current PHP version:
PHP Version [5.2] ( list of 5.2, 5.3, 5.4, 5.5, 5.6 available php versions)
Warning: Changing php modules and php options via PHP Selector for native php version is impossible
I selected 5.6 php version, after that error cleared on my wordpress blog site...
Warning: mysqli::mysqli(): Headers and client library minor version mismatch.
Headers:50547 Library:100026
I solved the above error by just rebuilding my Apache:
cPanel Version 56.0 (build 25)
Apache Version 2.4.18
PHP Version 5.5.30
MySQL Version 10.0.26-MariaDB
For WHM and cPanel, some versions need to explicty set mysqli to build.
Using WHM, under CENTOS 6.9 xen pv [dc] v68.0.27, one needed to rebuild Apache/PHP by looking at all options and select mysqli to build. The default was to build the deprecated mysql. Now the depreciation messages are gone and one is ready for future MySQL upgrades.
I ran into the same issue on centos7. Removing php-mysql and installing php-mysqlnd fixed the problem. Thanks Carlos Buenosvinos Zamora for your suggestion.
Here are my commands on centos7 just in case this can be of help to anybody as most of the answers here are based on Debian/Ubuntu.
To find the installed php-mysql package
yum list installed | grep mysql
To remove the installed php-mysql package
yum remove php55w-mysql.x86_64
To install php-mysqlnd
yum install php-mysqlnd.x86_64
Works for MariaDB 10.6.4-MariaDB, php56w, on centos 7.7
yum remove php56w-mysqli
yum install php56w-mysqlnd
Changing PHP version from 5.6 to 5.5 Fixed it.
You have to go to control panel > CGI Script and change PHP version there.

Upgrade PostgreSQL 8.1 to 8.3 on Debian Lenny, but zend php still recognize pgsql as version 8.1

The story goes like this:
I have Zend server CE PHP5.3 with all the modules available enabled running on Debian Etch.
I decided to upgrade Debian Etch to Lenny, then also upgraded PostgreSQL 8.1 to 8.3
Restored the database mydatabase --> $ psql mydatabase < schema_and_data.sql
Checked the web site that connects to a postgreSQL database and got this error.
Error: Failed to connect to database.
So I manually login to postgreSQL -> postgres#devserver:/$ psql mydatabase
Obviously postgreSQL is fine with mydatabase as my database
I checked phpinfo and PostgreSQL(libpq) Version : 8.1.1 (which was the previous version instead of the new 8.3)
I'm stuck at #6 at the moment.
Aside from doing the following that I think would fix it back to 'working condition':
Also downgrading postgreSQL 8.3 to 8.1 is not allowed as postgresSQL 8.1 is not supported on Lenny.
Setup my Debian box back to Etch and install zend/postgreSQL 8.1.
Any idea how to re-configure php-5.3-pgsql-zend on Lenny to recognize the new 8.3 version? Thanks!
If you haven't restarted your web server or php-cgi process, try that. They probably still have an old copy of libpq and/or the php pgsql stuff loaded.

Categories