php添加pdo_mysql.so的扩展

Posted 泥土里的绽放

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php添加pdo_mysql.so的扩展相关的知识,希望对你有一定的参考价值。

1. 首先进入你下载的php的安装包里找到pdo_mysql文件夹。

/usr/local/php-7.3.3/ext/pdo_mysql

ps:有些教程说从http://pecl.php.net/这个网站上下载pdo_mysql扩展,然后再编译安装。唉,兄弟啊,这个东西社区都不维护了,你还从上面下载个球球啊!!!!

大家一定要避免这个坑啊!!!!!

2. 执行phpize。

这里要注意,你要使用自己要添加扩展的php的phpize。什么意思呢?比如说你有php7 和 php7.3两个php版本,你要把扩展添加进7php7.3,那么你就需要使用php7.3的扩展,怎么使用呢?自行百度吧。

phpize是用来扩展php扩展模块的,通过phpize可以建立php的外挂模块

3. 配置扩展信息

./configure --with-php-config=/usr/local/php/bin/php-config // 这样是不行的!!!!!
./configure --with-php-config=/usr/local/php/bin/php-config --with-pdo-mysql=/usr/local/mysql (php的安装路径,也就是php的可执行文件)

4. 编译和安装

 make & make install

5. 修改php.ini文件

增加extension=pdo_mysql.so;

6. 重启php-fpm

sudo kill -USR2 进程号

遇到问题及解决方法:

1. nginx的错误日志

[error] 6910#6910: *1278203 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 218.107.211.81, server: caojiangjiang.qhrm.chunmiantest.qufenqi.com, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9800", host: "caojiangjiang.qhrm.chunmiantest.qufenqi.com"

2. php-fpm的错误日志

[18-Mar-2019 19:52:29] WARNING: [pool www] child 24699 exited with code 127 after 5484.614486 seconds from start
[18-Mar-2019 19:52:29] NOTICE: [pool www] child 23246 started

3. 浏览器显示

502

4. make test显示

@\'localhost\' (using password: NO)
SKIP PDO MySQL Bug #41698 (float parameters truncated to integer in prepared statements) [tests/bug_41698.phpt] reason: SQLSTATE[28000] [1045] Access denied for user \'root\'@\'localhost\' (using password: NO)
SKIP PDO MySQL Bug #41997 (stored procedure call returning single rowset blocks future queries) [tests/bug_41997.phpt] reason: SQLSTATE[28000] [1045] Access denied for user \'root\'@\'localhost\' (using password: NO)
SKIP Bug #42499 (Multi-statement execution via PDO::exec() makes connection unusable) [tests/bug_42499.phpt] reason: SQLSTATE[28000] [1045] Access denied for user \'root\'@\'localhost\' (using password: NO)
SKIP Bug #43371 (Memory errors in PDO constructor) [tests/bug_43371.phpt] reason: SQLSTATE[28000] [1045] Access denied for user \'root\'@\'localhost\' (using password: NO)
SKIP Bug #44454 (Unexpected exception thrown in foreach() statement) [tests/bug_44454.phpt] reason: SQLSTATE[28000] [1045] Access denied for user \'root\'@\'localhost\' (using password: NO)
SKIP Bug #44707 (The MySQL PDO driver resets variable content after bindParam on tinyint field) [tests/bug_44707.phpt] reason: SQLSTATE[28000] [1045] Access denied for user \'root\'@\'localhost\' (using password: NO)
SKIP Bug #45120 (PDOStatement->execute() returns true then false for same statement) [tests/bug_45120.phpt] reason: SQLSTATE[28000] [1045] Access denied for user \'root\'@\'localhost\' (using password: NO)
SKIP Bug #50323 (No ability to connect to database named \'t;\', no chance to escape semicolon) [tests/bug_50323.phpt] reason: SQLSTATE[28000] [1045] Access denied for user \'root\'@\'localhost\' (using password: NO)
SKIP Bug #51670 (getColumnMeta causes segfault when re-executing query after calling nextRowset) [tests/bug_51670.phpt] reason: SQLSTATE[28000] [1045] Access denied for user \'root\'@\'localhost\' (using password: NO)
SKIP PDO MySQL Bug #61207 (PDO::nextRowset() after a multi-statement query doesn\'t always work) [tests/bug_61207.phpt] reason: SQLSTATE[28000] [1045] Access denied for user \'root\'@\'localhost\' (using password: NO)
SKIP Bug #61411 (PDO Segfaults with PERSISTENT == TRUE && EMULATE_PREPARES == FALSE) [tests/bug_61411.phpt] reason: SQLSTATE[28000] [1045] Access denied for user \'root\'@\'localhost\' (using password: NO)
SKIP Bug #61755 (A parsing bug in the prepared statements can lead to access violations) [tests/bug_61755.phpt] reason: SQLSTATE[28000] [1045] Access denied for user \'root\'@\'localhost\' (using password: NO)
SKIP Bug #74376 (Invalid free of persistent results on error/connection loss) [tests/bug_74376.phpt] reason: SQLSTATE[28000] [1045] Access denied for user \'root\'@\'localhost\' (using password: NO)
SKIP PDO MySQL PECL bug #1295 (http://pecl.php.net/bugs/bug.php?id=12925) [tests/bug_pecl_12925.phpt] reason: SQLSTATE[28000] [1045] Access denied for user \'root\'@\'localhost\' (using password: NO)
SKIP PECL Bug #7976 (Calling stored procedure several times) [tests/bug_pecl_7976.phpt] reason: SQLSTATE[28000] [1045] Access denied for user \'root\'@\'localhost\' (using password: NO)
TEST 37/122 [tests/common.phpt]
Warning: opendir(/usr/local/php-7.3.3/ext/pdo_mysql/ext/pdo/tests): failed to open dir: No such file or directory in /usr/local/php-7.3.3/ext/pdo_mysql/run-tests.php on line 922
ERROR: cannot open directory: /usr/local/php-7.3.3/ext/pdo_mysql/ext/pdo/tests
Makefile:135: recipe for target \'test\' failed
make: *** [test] Error 1

其实这些问题的罪魁祸首就是在编译的时候没有编译导致的,问题排查的方法很重要,基础知识也很重要!!!

mysqlnd

另外可以通过md5sum来检测生成的pdo_mysql.so

使用 php -i 查看php在cli下面的详细信息  // 查看程序能够正确执行
使用 php -m查看php 在cli下面加载了哪些模块 

 

以上是关于php添加pdo_mysql.so的扩展的主要内容,如果未能解决你的问题,请参考以下文章

centos 6.5下编译安装php5.6,不支持pdo_mysql问题。

pdo sqlite 找不到驱动程序... php 文件未处理

VS中添加自定义代码片段——偷懒小技巧

Laravel基本使用

zabbix 安装时 到第三步时 database type 没有mysql选项

在 header.php 文件的 php 命令中添加 Google Ads 事件片段