Does the mysql client package version on webserver affect PHP queries? - php

I have two RHEL servers, one to host the PHP application, one to host the MySQL server.
Database server has MySQL Enterprise version 5.6.21 installed.
While getting the application server built, I asked that the rpm MySQL-client-advanced-5.6.21-1.el6.x86_64 be installed (to match server), but the hardware people don't like this version since 5.6.27 is available which addressed some vulnerabilities.
The question is the following:
Does the mysql client version on the application server affect the database queries coming from the PHP application?
We're using PDO to connect to and query MySQL.
If we do this, does the application server even need a mysql client library?
Please let me know if I can clarify.
Thanks!

PHP uses its own library/driver to connect to MySQL databases. The MySQL-client-advanced package is just the CLI mysql client. PHP does not use this.
For PHP (and PDO), you should install php-pdo and php-mysqlnd. php-mysqlnd is the "MySQL native driver" and contains some enhancements. It also contains the mysqli class and the pdo-mysql connector.
Note: php-mysqlnd versions are unrelated to the MySQL server version.

Quote from the Mysql website
MySQL Native Driver is a replacement for the MySQL Client Library (libmysqlclient). MySQL Native Driver is part of the official PHP sources as of PHP 5.3.0.
https://dev.mysql.com/doc/apis-php/en/apis-php-mysqlnd.html

Related

phpinfo() shows MySQL, PMA shows MariaDB

I am really confused about that
There is a phpinfo() output:
MySQL Support enabled
Client API version 5.5.40
MYSQL_MODULE_TYPE external
And the phpMyAdmin shows:
Server type: MariaDB
MariaDB is a fork of MySQL, but does that mean that MDB IS a MySQL database? Why phpinfo does not provide any information about MariaDB?
I am not sure if php is correctly configured on my hosting server, either not sure how to check it.
There is not necessarily a 1:1 correspondence between web servers running php and database servers running MySQL (or a different kind of database). The two things, even if running on the same system, are not connected or aware of each other, unless your php code specifically connects to the MySQL Server, and it isn't unheard of for a web app to connect to more than one MySQL Server.
So to expect the php info script to know anything about the MySQL Server is to expect the wrong thing.
Client API version 5.5.40
This means php has the MySQL client module that shipped with MySQL Server 5.5.40 and so is fully compatible with any MySQL Server up to and including version 5.5.40, and for the most part should also work with newer versions.
MariaDB is, for most purposes, fully compatible with MySQL Server, and the MySQL client library used by php.
Oracle owns MySQL. MariaDB is based on MySQL, and includes performance improvements of its own as well as some that were integrated from a third product, Percona Server, which is also MySQL compatible. MariaDB and Percona both are essentially drop-in replacements for MySQL. They look and act and communicate just like MySQL (with exceptions not relevant to the average user) and php doesn't know the difference, or care. A fourth variant is Amazon Aurora, also MySQL compatible, but some legacy capabilities are removed and others enhanced, in the interest of very high performance. Aurora is only available as a cloud service; the others can all be installed locally.
But php is only showing you its capability of connecting to MySQL -- not info about the MySQL server itself.

MySQL Server version different than MySQL version PHP is reporting

I'm running Wordpress on a RHEL 5 box. PHP is version 5.3.3, and we just upgraded the MySQL server on the box to 5.5.32 (up from 5.0.xx).
It seems like that upgrade went well, and Wordpress is running just fine. But what I don't understand is that PHP is continuing to report that it is using MySQL 5.0.95.
Anyone have a clue how I can tell PHP to use MySQL 5.5?
Just making my comment into answer as I added to it, it became more complete.
PHP is using 5.0.95 of the MySQL client library. PHP will not report on the version of MySQL being used on the MySQL server.
You can update your mysql client library on your PHP machine. Or better yet, you may consider re-compiling PHP with the MySQL Native Driver enabled, which will decouple you from having to have MySQL client library on your machine at all.
More info on MySQL native driver: http://www.php.net/manual/en/mysqlnd.overview.php
If you just want to upgrade your MySQL client package on RHEL 5, use RPM. I am not sure what the most recent rpm package for mysql client is named for RHEL 5, but the command would be something like this:
rpm -Uvh mysql-clientXXXX.rpm

Can MySQL seamlessly be replaced with MariaDB or are there things to change in this case?

If I replace a MySQL 5.1 server with a MariaDB Server (Maria & XtraDB storages) instead of MySQL (MyISAM & InnoDB), will most of MySQL client software (incl. applications made with PHP 5.2 and Java SE 1.6) ...
just remain working without any changes (with minor regressions maybe)?
Or will I have to replace/reconfigure client drivers (like use another JDBC driver class and connection string)?
Or will I have even to change application code?
http://kb.askmonty.org/v/mariadb-versus-mysql
All MySQL connectors (PHP, Perl, Python, Java, MyODBC, Ruby, MySQL C connector etc) works unchanged with MariaDB.
I have used Mariadb as replacement for Oracle's MySQL for years. It is faster and very reliable. Needs just little attention in apt, but nothing severe. Also, there is one small detail with Mariadb; it is seeing [error] "PHP Warning: mysql_connect(): Headers and client library minor version mismatch" in the logs. I haven't found any other solution to that other than to start manually compiling: askMonty.
$php -i | grep 'Client API'
Client API version => 5.3.7-MariaDB
Client API library version => 5.3.7-MariaDB
Client API header version => 5.1.61
Client API version => 5.3.7-MariaDB
just remain working without any changes (with minor regressions
maybe)?
You shouldn't have any issues as long as you replace with the same version. If you're currently are using MySQL 5.1, you can replace with MariaDB 5.1. If you are using 5.5, use the corresponding one. MariaDB v5.2 and v5.3 and enhanced versions of 5.1.
Or will I have to replace/reconfigure client drivers (like use another
JDBC driver class and connection string)?
You shouldn't. MySQL and MariaDB both use the same protocol and overall syntax, but there could be a few exceptions in some cases. The URL quoted in another answer is a great resource: http://kb.askmonty.org/v/mariadb-versus-mysql
Regarding the drivers' licenses, there are differences if you plan to distribute your project commercially. In that case I recommend you to double check the license terms and if you have any concerns, use the MariaDB/SkySQL versions of the connectors as suggested in another answer. Check http://www.skysql.com/downloads/java-cc-connectors-mariadb for details.
Or will I have even to change application code?
The application code should be unchanged.
Just a little feedback requarding the compatibility with mysql driver/CodeIgniter. I ran into the problems on BIT attributes types few minutes ago.
Value was not retrived from the server. It was always empty.
I was using standard CI database configuration which is using "mysql" driver.
After changing driver in the database.php to "mysqli" problem was solved.
Just the heads up that there can be some differences if you are using old mysql driver.
$db['default']['dbdriver'] = 'mysqli';
MariaDB client API version 5.5.40
MariaDB is MySQL evolved.
It is also the same developer who is behind MySQL and MariaDB. It is almost the same (if it is not, i can only say MariaDB is MySQL improved, dot).
You don't have to change nothing in your PHP.
Contrary to popular belief, the default Connector/J JDBC driver for connecting to and interacting with MySQL in Java does not play nicely with MariaDB. To work with MariaDB, you need to have your application use the Drizzle or SkySQL driver.
http://kb.askmonty.org/en/mariadb-faq-is-there-any-java-connector-for-mariadb-than-the-one-from-mysql

Pervasive & Linux

I'm interested in quering a Pervasive DB server running on a Windows platform from Linux.
Would anyone happen to know if this is possible, what's required and what resources there are for me to read up on it?
Thanks!
What version of Pervasive are you using? All versions since v8 (including v9 and v10) support a Linux client which is included with the Pervasive.SQL server engine. V9 and V10 clients are also available for download from the Pervasive website (http://www.pervasivedb.com/Database/Products/PSQLv10/Pages/PSQLOverview.aspx). Once you've got a client installed on the Linux machine, you can create an ODBC DSN or use the Btrieve API to access the data.
Most database have at least a command line client to connect to database. check your brand of database to see if you have such tools. For example, Mysql has mysql command line client for making query to MySql database. Otherwise, another way is you might want to try setting up ODBC with Perl.

PHP and Oracle using a thin driver

Is there a thin driver for Oracle available to be used with PHP (for example as an extension)?
I cannot install the OCI driver/client, but need to be able to access an Oracle database.
What is the problem with installing the OCI driver ?
The InstantClient version simply requires an unzip and setting a couple of environment variables.
The other option is exposing the database functionality through web services. 11g includes an inbuilt HTTP server.
Oracle released a jdbc driver written only in java, but (afaik) without the source code, so I doubt they will release a php (source code) driver. And never heard of an attempt by someone else.
But another question: "(for example as an extension)" You would be able to install an extension but not the oci8 extension?
There is no "thin" Oracle driver in PHP. You always need an external client library such as Oracle Instant Client - which is really easy to install.
Check http://www.oracle.com/technology/tech/php/pdf/underground-php-oracle-manual.pdf
(Also, Oracle has RPMs of PHP and Instant Client that can be used on RH Linux.)

Categories