参考:https://www.php.cn/topic/php7/457428.html
PHP7移除了mysql扩展,推荐使用mysqli或者pdo_mysql。
下载:
网址:http://git.php.net/?p=pecl/database/mysql.git;a=summary
安装:
git clone https://git.php.net/repository/pecl/database/mysql.git && cd mysql phpize ./configure --with-php-config=/usr/bin/php-config --with-mysql=mysqlnd make && make install
输出:
Installing shared extensions: /usr/lib64/php/modules/
设置:
在 php.ini 文件中添加:
; [mysql] extension = "mysql.so"
验证:
php -m
报错:
PHP Warning: PHP Startup: Unable to load dynamic library 'mysql.so' (tried: /usr/lib64/php/modules/mysql.so (/usr/lib64/php/modules/mysql.so: undefined symbol: mysqlnd_get_client_info), /usr/lib64/php/modules/mysql.so.so (/usr/lib64/php/modules/mysql.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
暂时无解。只能降级到 PHP5.6 。