What is the most up to date production version of mysqli ? - mysqli

Tough to figure out if I have an up to date version of mysqli or not.
I use this in a web page :
$link = mysqli_connect($hostname, $username, $password, $dbname);
printf("MYSQLi Client library version: %s<br>\n", mysqli_get_client_info());
The output is :
MYSQLi Client library version: mysqlnd 5.0.10 - 20111026 - $Id: e707c415db32080b3752b232487a435ee0372157 $
Well that is all well and nice .. but my MySQL rev is 5.5.30 base on this :
//connection to the database
$dbhandle = mysql_connect($hostname, $username, $password)
or die("Unable to connect to MySQL");
echo "Connected to ";
// print the MySQL server version
printf("MySQL server version: %s<br>\n", mysql_get_server_info());
Which results in :
Connected to MySQL server version: 5.5.30
Should I expect to see a mysqli rev of 5.5.x or am I wrong?
Any insight would be helpful.
This is Apache 2.4.4 and PHP 5.4.12 if that helps :
$ /usr/local/bin/php --version
PHP 5.4.12 (cli) (built: Feb 25 2013 19:25:44)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies
$ /usr/local/bin/httpd -v
Server version: Apache/2.4.4 (Unix)
Server built: Feb 28 2013 10:46:58

The mysqli extension has been built using a MySQL distribution which version was different from your (MySQL) server version:
http://php.net/manual/en/mysqli.installation.php
You'll notice the output refers to MYSQLi Client library version.
To obtain the version of your server distribution, you can execute the following query using the same PHP version of PHP and mysqli extension:
SELECT ##version;
$mysqli = new mysqli('host', 'username', 'my_secret_password...');
$result = $mysqli->query('SELECT ##version;');
print_r($result->fetch_array());

Related

Why is my Hive QL Query that I run in SSMS via Openquery through the Hortonworks ODBC Driver producing an error?

I set up a connection to a Hive server using the Hortonworks ODBC Driver for Apache Hive. Version info is below:
OS: Windows Server 2012 R2 Standard
Hive: 1.2.1000.2.6.5.4-1
Hadoop: 2.7.3.2.6.5.4-1
Hortonworks ODBC Driver for Apache Hive
ODBC Version: 03.80
Driver Version: 2.1.12.1017
Bitness: 64-bit
Locale: en_US
I can run the queries below using the connector that I configured in Teradata SQL Assistant with no issues. I set up my DSN as a linked server in SSMS. However, when I attempt to run the queries in SSMS using openquery, I have some issues. Info on my SQL Server is below:
Microsoft SQL Server 2016 (SP2-CU3) (KB4458871) - 13.0.5216.0 (X64) Sep 13 2018 22:16:01 Copyright (c) Microsoft Corporation Enterprise Edition (64-bit) on Windows Server 2012 R2 Standard 6.3 <X64> (Build 9600: ) (Hypervisor)
Here is some info on the table that I am querying:
Table Name: instrumentapps_event
Using OPENQUERY, I am capable of querying the Hive DB through SSMS with the following query:
SELECT * FROM OPENQUERY(KMhivehttp, 'select * from dmfwk_gold.instrumentapps_event')
The above query returns the contents of the desired table. However, the query below produces an error:
SELECT * FROM OPENQUERY(KMhivehttp, 'select * from dmfwk_gold.instrumentapps_event WHERE to_date(from_unixtime(UNIX_TIMESTAMP(load_ts,''yyyy/MM/dd''))) >= to_date(''2019-03-01'')')
The error is as follows:
Msg 7355, Level 16, State 1, Line 1
The OLE DB provider "MSDASQL" for linked server "KMhivehttp" supplied inconsistent metadata for a column. The name was changed at execution time.
How can I fix this?
While I'm unsure how to fix the problem that I previously faced (I suspect it to be a bug with the Hortonworks ODBC driver), I did discover a workaround.
Instead of running:
SELECT * FROM OPENQUERY(KMhivehttp,
'SELECT *
FROM dmfwk_gold.instrumentapps_event
WHERE to_date(from_unixtime(UNIX_TIMESTAMP(load_ts,''yyyy/MM/dd''))) >=
to_date(''2019-03-01'')
')
I now use:
SELECT * FROM OPENQUERY(KMhivehttp, 'select * from dmfwk_gold.instrumentapps_event')
WHERE load_ts >= CAST('2019-03-01' AS DATE);
This allows me to avoid any metadata errors.

How can I get perl MongoDB Admin module

I am trying the Mongodb admin module from CPAN
https://metacpan.org/pod/MongoDB::Admin
The exact sample code does not work , because the module does not have a MongoDB::Connection package
This is the script I am trying
use MongoDB;
use MongoDB::Admin;
my $connection = MongoDB::Connection->new(host => 'localhost', port => 27017);
my $admin = MongoDB::Admin->new('connection' => $connection);
my $ops = $admin->current_op();
MongoDB::Admin seems to be out of date. If you look at the MongoDB driver changelog you can see that at version 1.0 the MongoDB::Connection was dropped because it was deprecated.
The long-deprecated MongoDB::Connection class has been removed.
The latest version of MongoDB::Admin is 0.03 from July 2011. At that point, MongoDB was at version 0.43, but is now on 2.0.3. A lot has happened since then.
You might want to look for a different graphical user interface.

CentOS 6.7 and Windows MSSQL connection - FreeTDS and PHP

I searched for answers related to my question but not found what I'm looking for.
I have server with Linux CentOS 6.7. I need to connect to MS SQL Server 2005 on Windows Small Business Server 2003. In CentOS I installed FreeTDS and I managed to connect to SQL Server from terminal using this command:
# TDSVER=7.0 tsql -H ServerIPAdress -p 1433 -U username -P password
As far as I know this command bypass settings in freetds.conf.
Now I need to connect from PHP script. I'm using PDO extension and I tried this DSN string:
$db = new PDO("dblib:version=7.0;host=ServerIPAdress;dbname=Database;","username","password");
This leads me to first error:
Could not find driver
Ok, I understand that - my PHP 5.3.3 installation doesn't have installed PDO driver dblib.
My question: How can I install pdo_dblib driver in CentOS? Many tutorials and answers suggest to install through this command:
yum install php5-sybase
But that package doesn't exist:
No package php-sybase available.
If I check tsql configuration with command
tsql -C
I get these output:
Version: freetds v0.95
freetds.conf directory: /usr/local/etc
MS db-lib source compatibility: no
Sybase binary compatibility: no
Thread safety: yes
iconv library: yes
TDS version: 5.0
iODBC: no
unixodbc: yes
As I understand I need to configure FreeTDS:
./configure --enable-msdblib --with-pdo-dblib=/usr/local
But how can I configure FreeTDS after instalation? I tried to remove current version but I can't find way to do that. Also I tried to install another version but configuration doesn't change.
Any advice are appreciated.
When I run command # odbcinst -j I can see this output:
unixODBC 2.3.0
DRIVERS ...........: /usr/local/etc/odbcinst.ini
SYSTEM DATA SOURCES: /usr/local/etc/odbc.ini
FILE DATA SOURCES..: /usr/local/etc/ODBCDataSources
USER DATA SOURCES..: /root/.odbc.ini
SQLULEN Size.......: 8
SQLSETPOSIROW Size.: 8
Content of my freetds.conf:
# $Id: freetds.conf,v 1.12 2007/12/25 06:02:36 jklowden Exp $
#
# This file is installed by FreeTDS if no file by the same
# name is found in the installation directory.
#
# For information about the layout of this file and its settings,
# see the freetds.conf manpage "man freetds.conf".
# Global settings are overridden by those in a database
# server specific section
[global]
# TDS protocol version
tds version = 7.0
# 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 Sybase server
[egServer50]
host = symachine.domain.com
port = 5000
tds version = 7.0
# A typical Microsoft server
[MSServer]
host = 192.168.1.55
port = 1433
tds version = 7.0
odbcinst.ini:
[FreeTDS]
Description = FreeTDS v7.0
Driver = /usr/local/lib/libtdsodbc.so
UsageCount = 1
odbc.ini:
[MSSQL]
Driver = FreeTDS
Description = MSSQL Server Connection
TDS_Version = 7.0
Trace = No
Server = MSServer
Port = 1433
Database = MyDatabase
Username = DOMAIN\MyUsername
Password = MyPassword
I can make connection with isql command when I specify username and password:
# isql -v MSSQL "DOMAIN\MyUsername" MyPassword
But if I omit username and password isql generate error:
[S1000][unixODBC][FreeTDS][SQL Server]Unable to connect to data source
[01000][unixODBC][FreeTDS][SQL Server]Adaptive Server connection failed
I suspect that my username make problems because I have to use DOMAIN name followed by backslash before username when I connect to SQL Server 2005.
UPDATE:
I succesfully made connection in PHP and now I can run queries. I added this line on top of my script: putenv("FREETDSCONF=/usr/local/etc/freetds.conf")
Why is this necessary?

Create a sql server snapshot using powershell

I was attempting to use the code from here However PS says Exception calling "Create" with "0" argument(s): "Create failed for Database 'NewSnapshot'. "
What arguments is the script missing? Is there a better way of accomplishing a snapshot than what the script from the link provides?
I'm using the following version:
Microsoft SQL Server 2012 (SP1) - 11.0.3153.0 (X64)
Jul 22 2014 15:26:36
Copyright (c) Microsoft Corporation
Standard Edition (64-bit) on Windows NT 6.2 (Build 9200: )

Uncaught exception 'MongoConnectionException'

Fatal error: Uncaught exception 'MongoConnectionException' with message
'Failed to connect to: localhost:27017: Permission denied' in
/var/www/html/test.php:8 Stack trace: #0 /var/www/html/test.php(8):
MongoClient->__construct() #1 {main} thrown in /var/www/html/test.php
on line 8
Hi Mongo experts...
I am a developer wanting to try out MongoDB. So installed centoOS 6.5 64bit in a test machine (Dell E520 Intel Dual Core 4GB Ram), installed PHP (Apache was already present).
Then installed MongoDB (yum install mongo-10gen mongo-10gen-server), then installed "pecl install mongo" (install ok: channel://pecl.php.net/mongo-1.4.5), added extension=mongo.so to php.ini.
To install pecl, I installed few other things like C++ compiler & php-pear. php5-dev & php5-cli was not available in yum so installed php-devel & php-cli (installed versions are php-devel-5.3.3-27.el6_5.x86_64 & php-cli-5.3.3-27.el6_5.x86_64
I turned off iptables firewall. Ran mongo --host localhost:27017 from shell & connected without problems
[root#localhost ~]# mongo --host localhost:27017
MongoDB shell version: 2.4.8
connecting to: localhost:27017/test
>
These are the contents of test.php
<?php
ini_set('display_errors',1);
ini_set('display_startup_errors',1);
error_reporting(-1);
// connect
$m = new MongoClient();
//$m = new MongoClient("mongodb://localhost:27017");
// select a database
$db = $m->comedy;
// select a collection (analogous to a relational database's table)
$collection = $db->cartoons;
// add a record
$document = array( "title" => "Calvin and Hobbes", "author" => "Bill Watterson" );
$collection->insert($document);
// add another record, with a different "shape"
$document = array( "title" => "XKCD", "online" => true );
$collection->insert($document);
// find everything in the collection
$cursor = $collection->find();
// iterate through the results
foreach ($cursor as $document) {
echo $document["title"] . "\n";
}
?>
As you can see I have tried both
$m = new MongoClient(); & $m = new MongoClient("mongodb://localhost:27017");
But I am getting the same error. Where am I going wrong?
This problem is documented at http://ca3.php.net/manual/en/mongo.installation.php#mongo.installation.fedora
Red Hat,Fedora and CentOS:
The default Apache settings on these systems do not let requests make network connections, meaning that the driver will get "Permission denied" errors when it tries to connect to the database. If you run into this, try running:
$ /usr/sbin/setsebool -P httpd_can_network_connect 1
Then restart Apache. (This issue has also occurred with SELinux.)
Thanks for all your support!
Hope this thread helps someone from going in circles!