php 标头和客户端库次要版本不匹配
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10759334/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Headers and client library minor version mismatch
提问by Ian Hunter
In PHP I'm getting the following warning whenever I try to connect to a database (via mysql_connect)
在 PHP 中,每当我尝试连接到数据库时都会收到以下警告(通过mysql_connect)
Warning: mysql_connect(): Headers and client library minor version mismatch. Headers:50162 Library:50524
警告:mysql_connect():标头和客户端库次要版本不匹配。标题:50162 库:50524
In my php -ioutput I have the following values listed under mysqli
在我的php -i输出中,我在 mysqli 下列出了以下值
Client API library version => 5.5.24
Client API header version => 5.1.62
客户端 API 库版本 => 5.5.24
客户端 API 标头版本 => 5.1.62
I've tried updating php5-mysql andphp 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?
我已经尝试更新 php5-mysql和php,但我已经使用了它们的最新版本。如何更新标题版本,以便不再看到此警告?
EDIT
编辑
My MySQL files should all be updated to be the latest version:
我的 MySQL 文件应该全部更新为最新版本:
$ 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
采纳答案by dAm2K
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.
您的 PHP 是用 MySQL 5.1 编译的,但现在它正在链接 5.5.X 系列的 mysql 库。您必须将 PHP 升级到使用 MySQL 5.5 编译的版本或将 mysql 客户端库恢复到 5.1.x。
回答by ken
I am using MariaDB and have the similar problem.
我正在使用 MariaDB 并且有类似的问题。
From MariaDB site, it is recommended to fix it by
从MariaDB 站点,建议通过以下方式修复它
- Switch to using the mysqlnd driver in PHP (Recommended solution).
Run with a lower error reporting level:
$err_level = error_reporting(0); $conn = mysql_connect('params'); error_reporting($err_level);- Recompile PHP with the MariaDB client libraries.
- Use your original MySQL client library with the MariaDB.
- 切换到使用 PHP 中的 mysqlnd 驱动程序(推荐解决方案)。
以较低的错误报告级别运行:
$err_level = error_reporting(0); $conn = mysql_connect('params'); error_reporting($err_level);- 使用 MariaDB 客户端库重新编译 PHP。
- 将您的原始 MySQL 客户端库与 MariaDB 结合使用。
My problem fixed by using the mysqlnd driver in Ubuntu:
通过在 Ubuntu 中使用 mysqlnd 驱动程序解决了我的问题:
sudo apt-get install php5-mysqlnd
Cheers!
干杯!
[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
[更新:额外信息] 安装此驱动程序还解决了以字符串形式返回整数值的 PDO 问题。要保持类型为整数,安装 mysqlInd 后,执行此操作
$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);
回答by Carlos Buenosvinos Zamora
For new MySQL 5.6 family you need to install php5-mysqlnd, not php5-mysql.
对于新的 MySQL 5.6 系列,您需要安装 php5-mysqlnd,而不是 php5-mysql。
Remove this version of the mysql driver
删除这个版本的mysql驱动
sudo apt-get remove php5-mysql
And install this instead
并安装它
sudo apt-get install php5-mysqlnd
回答by marek
The same works for MySQL:
这同样适用于 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.
我读过这个线程试图找到 MySQL 的解决方案,我也看到了 ken 的答案,但我忽略了 MariaDB 的解决方案,那样浪费了几个小时。我不清楚这同样适用于 MySQL。这篇文章只是为了让你节省我失去的几个小时。
回答by Machavity
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 XXrepresents 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.
此错误的根本原因是 PHP 前段时间将自身与 MySQL Client 库分离。所以发生的事情(主要是在较旧的 linux 编译上)是人们将针对给定的 MySQL 客户端构建编译 PHP (意味着安装的 MySQL 版本无关紧要)而不是升级(在 CentOS 中,这个包被列为mysqlclientXX,其中XX代表包号)。这也允许包维护者支持较低版本的 MySQL。这是一种混乱的方法,但鉴于 PHP 和 MySQL 如何使用不同的许可,这是唯一的方法。
MySQLNDsolves 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.
MySQLND通过使用 PHP 自己的本地驱动程序(ND)解决了这个问题,该驱动程序不再依赖于 MySQL Client。它还针对您正在使用的 PHP 版本进行编译。这是一个更好的解决方案,如果没有其他原因,MySQLND 是为了让 PHP 与 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.
如果您无法安装 MySQLND,您实际上可以安全地忽略大多数情况下的此错误。这只是一个仅供参考的通知。只是听起来很可怕。
回答by Sithsu
To compile php from source with MySQL native driver (mysqlnd),
要使用MySQL 本机驱动程序 (mysqlnd)从源代码编译 php ,
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.
从/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.
使用这些选项可以包含一个或多个 PHP MySQL 扩展。
如果未将值传递给这些选项,或者值为mysqlnd,则将使用 MySQL 本机驱动程序。
回答by OpenWebWar
I got same php warring in my wordpress site...
我在我的 wordpress 网站上遇到了同样的 php War...
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
错误:警告:mysql_connect():标头和客户端库次要版本不匹配。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 )
原因:我将 wp 4.2 更新为 4.5 版本(PHP 和 MySql 不匹配)
I changed wp-db.php on line 1515
我在第 1515 行更改了 wp-db.php
$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
它在我的 wordpress 网站上没有交战错误
回答by OpenWebWar
If u had access cpanel or whm for domain web hosting ...
如果您可以访问域虚拟主机的 cpanel 或 whm ...
In cPanel, Go to "Softwares and services" tab, >> and then click "Select PHP Version" >> set your desired version of php...
在 cPanel 中,转到“软件和服务”选项卡,>> 然后单击“选择 PHP 版本”>> 设置所需的 php 版本...
Eg. Current PHP version:
例如。当前 PHP 版本:
PHP Version [5.2] ( list of 5.2, 5.3, 5.4, 5.5, 5.6 available php versions)
PHP 版本 [5.2](5.2、5.3、5.4、5.5、5.6 可用 php 版本列表)
Warning: Changing php modules and php options via PHP Selector for native php version is impossible
警告:无法通过 PHP Selector 为原生 php 版本更改 php 模块和 php 选项
I selected 5.6 php version, after that error cleared on my wordpress blog site...
我选择了 5.6 php 版本,在我的 wordpress 博客网站上清除了该错误后...
回答by Dot Online Services
Warning: mysqli::mysqli(): Headers and client library minor version mismatch.
Headers:50547 Library:100026
I solved the above error by just rebuilding my Apache:
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
回答by Bob P
For WHM and cPanel, some versions need to explicty set mysqli to build.
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.
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.


