背景
部署php项目,查看httpd的error.log时发现有如下报错:
[Fri Sep 25 09:39:36.906590 2020] [:error] [pid 12835] [client 192.168.235.20:52444] PHP Warning: mysql_connect(): Headers and client library minor version mismatch. Headers:50564 Library:50645 in /var/www/html/v4/lib/qeephp/library/db/adapter/mysql.php on line 66, referer: https://pro4.aishu.cn/v4/public/index.php?namespace=user&controller=accountsubsidy
意思很好理解,就是数据库版本和客户端版本不匹配,我使用的是MySQL5.7.29,php-mysql安装的是5.4.16-48.el7。
解决办法
卸载php-mysql:
[root@node-23 logs]# yum remove php-mysql -y
Loaded plugins: fastestmirror
Resolving Dependencies
--> Running transaction check
---> Package php-mysql.x86_64 0:5.4.16-48.el7 will be erased
--> Finished Dependency Resolution
Dependencies Resolved
=============================================================================================================================================================================================
Package Arch Version Repository Size
=============================================================================================================================================================================================
Removing:
php-mysql x86_64 5.4.16-48.el7 @base 232 k
Transaction Summary
=============================================================================================================================================================================================
Remove 1 Package
Installed size: 232 k
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Erasing : php-mysql-5.4.16-48.el7.x86_64 1/1
Verifying : php-mysql-5.4.16-48.el7.x86_64 1/1
Removed:
php-mysql.x86_64 0:5.4.16-48.el7
Complete!
安装高版本的php-mysqlnd:
[root@node-23 logs]# yum install php-mysqlnd -y
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
base | 2.3 kB 00:00:00
extras | 1.5 kB 00:00:00
updates | 1.5 kB 00:00:00
Resolving Dependencies
--> Running transaction check
---> Package php-mysqlnd.x86_64 0:5.4.16-48.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
=============================================================================================================================================================================================
Package Arch Version Repository Size
=============================================================================================================================================================================================
Installing:
php-mysqlnd x86_64 5.4.16-48.el7 base 174 k
Transaction Summary
=============================================================================================================================================================================================
Install 1 Package
Total download size: 174 k
Installed size: 461 k
Downloading packages:
php-mysqlnd-5.4.16-48.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-48.el7.x86_64 1/1
Verifying : php-mysqlnd-5.4.16-48.el7.x86_64 1/1
Installed:
php-mysqlnd.x86_64 0:5.4.16-48.el7
Complete!
重启httpd服务:
[root@node-23 logs]# systemctl restart httpd.service
欢迎访问我的个人博客:Lemon - 万事顺遂