Windows client program refuses to cooperate with linux postgresql database - linux

I have PostgreSQL database engine running on MS-Windows 7 Cz. A client program, which communicates with this pgsql database, runs the MS-Windows 7 Cz, too. The program is installed with US-English language mutation.
In this default configuration everything goes well. But I want to pair the Windows client program with the PostgreSQL database running on Linux.
The first try failed, but on both sides no reasonable information was logged.
I made some comparisons of the Linux db. crated fractions vs. the MS-Windows db. I only found the difference in the COLLATION settings. On Linux db. the default is "cs_CZ.UTF-8", but on the MS-W db. there is "Czech_Czech Republic.1250".
I do really not know what the COLLATION is for, because on the both OS in the dbs. the default internal encoding is utf-8. Does it means the that the MS-W client speaks to db. using cp1250, while the Linux db. expects the utf8? (Every explanation of COLLATIN speaks about the locale alphabet order?)
It is impossible to change the client behavior, but due to the stability and other database parameters it is highly important to migrate to the Linux server platform.
Can somebody give me some helpful guidelines, how to prepare the Linux PostgreSQL database in ought to be accepted by the MS-Windows client program? The program support team did not (cannot or may be must not) helped me over two month discussion.
Thanks in advance

Yes, finally it was very easy: the critical difference between the MS-Windows configuration and the Linux one, it was the Authentication conf module: pg_hba.conf! Its content is by default in Linux more tolerant to developer working on locahost connection:
host all all 127.0.0.1/32 trust
but in MS-Windows the connection rules are very strict:
host all all 127.0.0.1/32 md5
host all all 0.0.0.0/0 md5
The client program has no configuration file that may change its behavior.
Lots of polling with Wire-Shark was made to note such simple difference.

Related

Accessing a Pervasive 13 Database for Ubuntu Server 18.04

I've successfully installed the Pervasive 13's 64bit Client onto Ubuntu Server 18.04.
How can I now establish a connection to the Pervasive 13 server (which is installed on a Windows 2008 R2 server) and perform a sql query?
I'm extremely confused by the documentation, which directs me to the bcfg tool after client installation. I'm not clear if that tool is for configuring the server or for setting up the client connection. Ether way, the documentation is too abstract for my comprehension; I need concrete examples of someone successfully establishing a connection to (at least a hypothetical Pervasive server located at some hypothetical ip address) and NOT JUST abstract syntax that never shows an example of SQL statement being submitted from command line Linux.
Seriously, the documentation covers so much detail of stuff I don't immediately care about, that I can never seem to figure out my practical needs which are to simply establish a connection to the database, perform a SQL query, and get a result set.
The installation of the client should have sensible defaults, and the documentation, after installation, should focus on getting you connected and running sql statements as quickly as possible, instead of going on and on about details that are only of interest if the defaults aren't sensible. Let me connect first! Then if I have a problem, only then do I care to learn further detail about other aspects of configuring the connection.
Pervasive is such an obscure database server, that I'm left with only this documentation to figure this out. Any other database would probably have YouTube videos that show you how to install the client, and start making some SQL queries and getting result sets.
Someone at Actian, ought to be kind enough to make a quick start video for the client on Ubuntu Server that quickly covers installation and finishes where you're submitting sql queries and get result sets. After all, that's the purpose of database client.
Can someone please provide some concrete examples of how I can turn this successful installation into a relationship with the database server where I can submit SQL queries and receive result sets?
I'm not sure why the documentation points to bcfg.
If the Client is installed and didn't display any errors, you need to add an ODBC DSN using dsnadd (https://docs.actian.com/psql/PSQLv13/index.html#page/uguide%2Fuguide.dsnadd.htm%23ww68699). An example of creating a client side DSN pointing to a remote database is:
dsnadd -dsn=clientDemodata -db=Demodata -host=WindowsServerName
(where clientDemodata is the DSN created on the Linux box, Demodata is the PSQL database on the remote server called WindowsServerName).
Once the DSN has been added, you should be able to use isql or isql64 (https://docs.actian.com/psql/PSQLv13/index.html#page/uguide%2Fuguide.isql.htm%23ww138933) to execute a query.
Running isql / isql64 with just the DSN will let you execute SQL queries interactively:
isql64 clientDemodata
An example of running isql using a file as input for the SQL statement(s) is:
cat two-queries.sql | isql clientDemodata -b
If you've done all that, what errors or behavior are you seeing?

Restore pg_basebackup on Linux which was created from a Windows hosted database cluster

Currently I am doing some Research on how to set up streaming replication for a HA postgresql architecture. But this issue is also relevant for us for backup/restore and maintenance in mixed environments in general.
Our "main" postgresql server is running on a Windows box. I am using pg_dump to create logical backups every day and pg_basebackup and WAL archiving to create a full backup which should provide PITR (I have not tested this yet).
Next step is to set up a slave machine which holds a replica via streaming replication. Due to the better Support of the postgresql ecosystem, this new host is running Ubuntu Server 16.04 LTS.
With pg_basebackup -h <main host> -D <datadirectory> --xlog-method=stream I initialized the slave datadirectory.
Then I had to fix some symbolic links onto tablespace files, as these were pointing on Windows paths instead of the Linux filesystem.
Next I created the recovery.conf file with standby_mode = on and the connectioninfo
I verified, that the Server is configured as hot_standby = on and started the daemon
Now I am running into issues as postgres tells me, that the "database locale (English_United_States.1252 which is obviously Windows specific) is incompatible with operating System"
Well, I am aware, that 1252 is a Windows specific locale and that I should use en_US.UTF8 on Linux, BUT in a mixed Environment like this, should I:
Init our main DB on Windows also with an en_US.UTF8 locale?
Is that even possible?
Why is the pg_basebackup format Operating System specific, or is there a backup Format which is not?
Is there any command line flag to set to translate this?
I would also appreciate it to use only Linux (or even only Windows), but I am afraid our customers will rely on both Operating Systems quite a while.
You cannot restore file system backups like the one that pg_basebackup creates on a different architecture, like restore a backup from Windows on Linux.
It is also impossible to have streaming repication in such a scenario.
From PostgreSQL v10 on, you might consider logical replication.

How do I set up a embedded MySQL client in Qt

I'm trying to set up my embedded Linux machine as a MySQL client, in order to connect to a external MySQL server (running on a remote machine). sqlite is not an option.
I understand, thanks to Basile Starynkevitch that I have to use libmysqlclient (because that is the only library to run such a connection and dealing with the MySQL client/server protocol on the client side).
Qt stats that:
You need the MySQL header files and as well as the shared library
libmysqlclient.so. Depending on your Linux distribution you may need
to install a package which is usually called "mysql-devel".
Did someone did this and can point out to the right package?
Yes, assuming what you want to do is use the QtSql API to access a MySQL database without connecting to an external MySQL server. With the embedded server library, the server runs in the same process as your client Qt Application, similar to how SQLite works.
One caveat though: the libmysqld embedded server library is deprecated as of MySQL 5.7.17 and will be removed in MySQL 8.0. (as mentionned on http://dev.mysql.com/doc/refman/5.7/en/libmysqld.html)
Your question is confusing and seems contradictory.
Either you want to work with an external MySQL server, and that means that your application opens a (tcp(7) socket) connection to some remote machine running mysqld. Then you have to use libmysqlclient (because that is the only library to run such a connection and dealing with the MySQL client/server protocol on the client side).
If that mysqld server is running as a different process on the same embedded Linux system you should have some way to start it (probably as part of the init scripts on it). Then you still use a socket communication to it, and you still need libmysqlclient. A possible difference with a remote machine running mysqld might be (but I am not sure) the socket family. Perhaps libmysqlclient is using unix(7) sockets in the special case of connecting to a server on the same machine.
Or you don't want any external server. You might consider libmysqld but as Romain answered it is deprecated and is becoming unsupported (so I feel that would be a very bad choice). Then all the database code is running on your embedded Linux computer, which also has all the data storage. In that case (relational database & data & storage on the same embedded Linux computer), I would recommend using sqlite instead because it is well supported and quite stable.
If your mysqld daemon is running on a remote machine you cannot (realistically) avoid libmysqlclient (otherwise you'll need to rewrite most of it).
I ended up doing the following:
Installing MySQL on my embedded Linux and tested it with
mysql --host=1.2.3.4 --user=Foo --password=FooPass testdb
When an MySQL server is runing on 1.2.3.4.
I recompiled Qt with the -sql-mysql option, so the new compiled version will include Qt MySQL plugin.
Test if Qt MySQL plugin is supported with the next code:
QStringList driverslist = QSqlDatabase::drivers();
QString str;
foreach (str, driverslist) { qDebug() << str }
Expected output is:
QMYSQL3
QMYSQL
Test that driver loaded as expected with the next code:
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
db.setHostName("1.2.3.4");
db.setDatabaseName("TestDB");
db.setUserName("Foo");
db.setPassword("FooPass");
bool ok = db.open();
if(ok)
{
// "Connected"
}

Connecting to Firebird on Linux from a CGI application under Apache gives permissions error

I'm writing a small program in Free Pascal on Linux and connecting to a Firebird database on the same server. For testing, I initially wrote a console application using the TIBConnection components in FP and successfully connected to the Firebird database and listed records from one of the tables.
Now I'm wanting to do the same thing from a CGI application under Apache. A sample CGI app with various parameters displays different HTML results via the WebBroker "actions" like expected.
So both preliminary tests, connecting to Firebird and getting a CGI web app running, have worked. The final test is to combine them and that's where my problem is.
Whenever I run the test cgi application and try to connect to the Firebird database, I get a "permission denied" error. I've left the username, password, and port all at defaults, have checked the firewall, switched between "localhost" and "127.0.0.1" and several other things including setting the permissions on the database file to read/write globally (for temporary testing, of course).
I've found lots of information on the internet about connecting to Firebird on Linux and lots of information about writing CGI applications, but very little where it combines the two subjects. I'm sure there's a subtle yet important security or firewall issue, but it eludes me.
CentOS 6.6 64-bit on a virtual machine
Firebird 2.1.7 64-bit
Lazarus 1.4.0 64-bit
Anyone have any suggestions on what I could try?
I figured out how to get it working by reading the solution to a different problem. Not sure why disabling the firewall didn't work (I had to completely uninstall it) and don't know what SELinux is yet (had to set it to "permissive"), but I will need to study those two issues so the live server won't be left vulnerable.

Using Linux to execute a query from Windows server by ODBC connection

Here is the problem: We have a client that uses Progress Openedge database, we need to execute queries on this database from our servers.
Currently the drivers are installed on our Windows server, and the PHP code uses ODBC to run the queries.
Now we would like to move the code to a Linux server. We tried before to work with their linux drivers but that attempt has failed.
The question is, Is it possible somehow to run PHP code on a linux server, this code communicates with the Windows server, runs the query on the Windows server, and return the results to Linux?
How would you access to this problem.
Thanks!
Yes, it's possible. Your question boils down to "how can my Linux server ask my Windows server to do something" (where the "something" happens to be "talk to a database"), and there are a variety of ways to accomplish that. You could run a web service (RESTful or SOAP) on the Windows server, for example.
Make sure you think about security: if you deploy a service on your Windows server that lets remote clients modify a database, you have to be mindful of which remote clients are allowed to use that service. The last thing you want to do is accidentally allow random strangers to run arbitrary queries against your database.
We have a Knowledgebase Article detailing some setup procedures for Linux installations; it also has a video explaining some aspects of the setup. If the other answered haven't provided a complete solution for you, hopefully our article can at least get you started in the right direction.
Also keep in mind that depending on your version of OE, the driver libraries may be different.

Resources