Linux解决Warning: mysql_connect(): Headers and client library minor version mismatch. 警告

Linux解决Warning: mysql_connect(): Headers and client library minor version mismatch. 警告

这两天用阿里云服务器重新部署网站服务器后,打开某php页面出现了如下警告:Warning: mysql_connect(): Headers and client library minor version mismatch. Headers:50547 Library:50631 in /XXX(某某目录)/wp-db.php on line 1520,虽然是警告,但是有的界面会因此打不开,甚是头疼,前不久用的是腾讯云服务器同样的部署方式并没有出现这个警告,一头雾水。

使用:

php -i|grep Client

查询当前Client 版本,结果如下:

Client API version => 5.6.31
Client API library version => 5.6.31
Client API header version => 5.5.47-MariaDB
Client API version => 5.6.31

好吧,header version => 5.5.47-MariaDB 出现个奇葩,版本号不一样,怪不得报错了。据某大牛说,版本不兼容,需升级MariaDB版本至少到5.6.31或许可以解决。我的系统是CentOS7.2版本,众所周知,CentOS从7.x系列版本开始抛弃了MySQL,缺省安装的是MariaDB,虽然MariaDB兼容MySQL,但是我还是比较喜欢MySQL,所以我给服务器强制安装了MySQL,也希望一直用下去,对于这个情况,升级MariaDB这条路是不能走了。考虑当前安装的是php-mysql驱动,而当前的php版本比较新,想到这个奇葩是不是因为驱动版本较低造成的,于是尝试以下操作:

[root@xiaobing html]# php -i|grep client
PHP Warning:  Unknown: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in Unknown on line 0
MYSQL_LIBS => -L/usr/lib64/mysql -lmysqlclient 
[root@xiaobing html]# php -i|grep Client
PHP Warning:  Unknown: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in Unknown on line 0
Client API version => 5.6.41
Client API library version => 5.6.41
Client API header version => 5.5.56-MariaDB
Client API version => 5.6.41
[root@xiaobing html]# yum remove php-mysql
Loaded plugins: fastestmirror, langpacks
Resolving Dependencies
--> Running transaction check
---> Package php-mysql.x86_64 0:5.4.16-45.el7 will be erased
--> Finished Dependency Resolution

Dependencies Resolved

=========================================================================================================================================================
 Package                              Arch                              Version                                     Repository                      Size
=========================================================================================================================================================
Removing:
 php-mysql                            x86_64                            5.4.16-45.el7                               @os                            232 k

Transaction Summary
=========================================================================================================================================================
Remove  1 Package

Installed size: 232 k
Is this ok [y/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Erasing    : php-mysql-5.4.16-45.el7.x86_64                                                                                                        1/1 
  Verifying  : php-mysql-5.4.16-45.el7.x86_64                                                                                                        1/1 

Removed:
  php-mysql.x86_64 0:5.4.16-45.el7                                                                                                                       

Complete!
[root@xiaobing html]# yum install php-mysqlnd
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package php-mysqlnd.x86_64 0:5.4.16-45.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=========================================================================================================================================================
 Package                                Arch                              Version                                    Repository                     Size
=========================================================================================================================================================
Installing:
 php-mysqlnd                            x86_64                            5.4.16-45.el7                              os                            174 k

Transaction Summary
=========================================================================================================================================================
Install  1 Package

Total download size: 174 k
Installed size: 462 k
Is this ok [y/d/N]: y
Downloading packages:
php-mysqlnd-5.4.16-45.el7.x86_64.rpm                                                                                              | 174 kB  00:00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : php-mysqlnd-5.4.16-45.el7.x86_64                                                                                                      1/1 
  Verifying  : php-mysqlnd-5.4.16-45.el7.x86_64                                                                                                      1/1 

Installed:
  php-mysqlnd.x86_64 0:5.4.16-45.el7                                                                                                                     

Complete!
[root@xiaobing html]# systemctl restart httpd.service
[root@xiaobing html]# systemctl restart mysqld.service
[root@xiaobing html]# php -i|grep Client
PHP Warning:  Unknown: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in Unknown on line 0
Client API version => mysqlnd 5.0.10 - 20111026 - $Id: e707c415db32080b3752b232487a435ee0372157 $
Client API library version => mysqlnd 5.0.10 - 20111026 - $Id: e707c415db32080b3752b232487a435ee0372157 $
Client API version => mysqlnd 5.0.10 - 20111026 - $Id: e707c415db32080b3752b232487a435ee0372157 $

OK,版本全统一了,问题解决。

  • 3
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值