Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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
like image 952
Ian Hunter Avatar asked May 25 '12 18:05

Ian Hunter


3 Answers

I am using MariaDB and have a similar problem.

From MariaDB site, it is recommended to fix it by

  1. Switch to using the mysqlnd driver in PHP (Recommended solution).
  2. Recompile PHP with the MariaDB client libraries.
  3. 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);
like image 65
ken Avatar answered Oct 21 '22 19:10

ken


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
like image 35
Carlos Buenosvinos Zamora Avatar answered Oct 21 '22 19:10

Carlos Buenosvinos Zamora


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.

like image 32
dAm2K Avatar answered Oct 21 '22 17:10

dAm2K