我正在使用Raspbian 9。
我安装了php和php-mysql
>sudo sudo apt-get install php7.0-mysql
Reading package lists... Done
Building dependency tree
Reading state information... Done
php7.0-mysql is already the newest version (7.0.30-0+deb9u1).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
但是我的php脚本抛出一个错误,指出myscli类不可用
>php prodDataSender.php
PHP Fatal error: Uncaught Error: Class 'mysqli' not found in /home/pi/prodDataSender.php:12
Stack trace:
#0 {main}
thrown in /home/pi/prodDataSender.php on line 12
这是导致错误的非常简单的一行:
// Create connection
$conn = new mysqli($host, $user, $password, $db);
这是php -i grep:
>php -i | grep mysql
Additional .ini files parsed => /etc/php/7.0/cli/conf.d/10-mysqlnd.ini,
/etc/php/7.0/cli/conf.d/20-mysqli.ini,
/etc/php/7.0/cli/conf.d/20-mysqlnd.ini,
/etc/php/7.0/cli/conf.d/20-pdo_mysql.ini,
pi@valrb2:~ $
我尝试过:
重新加载/重启apache2 重启 再次删除/安装php / php-mysql
什么都没有。
我不知道现在要搜索什么。
编辑:
如果我添加:
extension=mysqli.so
我明白了:
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/20151012/mysqli.so' - /usr/lib/php/20151012/mysqli.so: undefined symbol: mysqlnd_connect in Unknown on line 0
PHP Fatal error: Uncaught Error: Class 'mysqli' not found in /home/pi/prodDataSender.php:12
Stack trace:
#0 {main}
thrown in /home/pi/prodDataSender.php on line 12
答案 0 :(得分:1)
使用清除功能重新安装php7.0-mysql:sudo apt-get purge php7.0-mysql && sudo apt-get install php-mysql
请验证输出php -r 'phpinfo();' | grep -i mysqli