• 前提:网页报错

为解决问题:Undefined class constant 'MYSQL_ATTR_INIT_COMMAND'

linux下php开启pdo扩展-LMLPHP

解决方案 :

  • 下载安装PHP_MYSQL扩展

wget http://pecl.php.net/get/PDO_MYSQL-1.0.2.tgz
tar xvf PDO_MYSQL-1.0.2.tgz
cd PDO_MYSQL-1.0.2
/usr/local/php-5.6.30/bin/phpize
./configure --with-php-config=/usr/local/php-5.6.30/bin/php-config --with-pdo-mysql=/usr/local/mysql-5.7.21/ --with-zlib-dir=/usr/local/lib
make
make install

linux下php开启pdo扩展-LMLPHP

  • 报错解决/usr/local/src/PDO_MYSQL-1.0.2/php_pdo_mysql_int.h:25:19: fatal error: mysql.h: No such file or directory

ln -s /usr/local/mysql-5.7./include/* /usr/local/include/

linux下php开启pdo扩展-LMLPHP

linux下php开启pdo扩展-LMLPHP

  • PDO_MYSQL安装成功后,继续,开启PHP对应扩展

vim /usr/local/php-5.6./etc/php.ini

#在文件末尾增加 extension=pdo_mysql.so

linux下php开启pdo扩展-LMLPHP

linux下php开启pdo扩展-LMLPHP

  • 报错解决libmysqlclient.so.20: cannot open shared object file: No such file or directory in Unknown

ln -s /usr/local/mysql-5.7./lib/libmysqlclient.so. /usr/lib64/libmysqlclient.so.

linux下php开启pdo扩展-LMLPHP

  • 重启PHP服务

linux下php开启pdo扩展-LMLPHP

 Done!

 

参考地址:

https://blog.csdn.net/houdaiye/article/details/51965640

http://www.codeweblog.com/pdo_mysql-1-0-2-php_pdo_mysql_int-h-25-19-%E8%87%B4%E5%91%BD%E9%94%99%E8%AF%AF/

https://www.cnblogs.com/eRrsr/p/8258333.html

05-11 15:21