Q: Ubuntu16.04 PHP7.0 不能用MYSQLi方式鏈接MySQL5.7數據庫php
A: 執行如下2條命令解決:html
apt-get install php-mysqlmysql
service apache2 restart
sql
php -m 執行後會多如下4個模塊:數據庫
mysqliapache
mysqlndjson
PDOubuntu
pdo_mysqlbash
✘ ⚡ root@NanoPi-NEO2 /var/www/html mysql --version mysql Ver 14.14 Distrib 5.7.22, for Linux (aarch64) using EditLine wrapper ⚡ root@NanoPi-NEO2 /etc/php php -v PHP 7.0.30-0ubuntu0.16.04.1 (cli) ( NTS ) Copyright (c) 1997-2017 The PHP Group Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies with Zend OPcache v7.0.30-0ubuntu0.16.04.1, Copyright (c) 1999-2017, by Zend Technologies ⚡ root@NanoPi-NEO2 /etc/php ⚡ root@NanoPi-NEO2 /etc/php/7.0/apache2 apt-get install php-mysql Reading package lists... Done Building dependency tree Reading state information... Done The following additional packages will be installed: php7.0-mysql The following NEW packages will be installed: php-mysql php7.0-mysql 0 upgraded, 2 newly installed, 0 to remove and 9 not upgraded. Need to get 104 kB of archives. After this operation, 459 kB of additional disk space will be used. Do you want to continue? [Y/n] Get:1 http://ports.ubuntu.com/ubuntu-ports xenial-updates/main arm64 php7.0-mysql arm64 7.0.30-0ubuntu0.16.04.1 [102 kB] Get:2 http://ports.ubuntu.com/ubuntu-ports xenial-updates/main arm64 php-mysql all 1:7.0+35ubuntu6.1 [1,928 B] Fetched 104 kB in 2s (40.3 kB/s) debconf: delaying package configuration, since apt-utils is not installed Selecting previously unselected package php7.0-mysql. (Reading database ... 49593 files and directories currently installed.) Preparing to unpack .../php7.0-mysql_7.0.30-0ubuntu0.16.04.1_arm64.deb ... Unpacking php7.0-mysql (7.0.30-0ubuntu0.16.04.1) ... Selecting previously unselected package php-mysql. Preparing to unpack .../php-mysql_1%3a7.0+35ubuntu6.1_all.deb ... Unpacking php-mysql (1:7.0+35ubuntu6.1) ... Processing triggers for libapache2-mod-php7.0 (7.0.30-0ubuntu0.16.04.1) ... Processing triggers for php7.0-fpm (7.0.30-0ubuntu0.16.04.1) ... Setting up php7.0-mysql (7.0.30-0ubuntu0.16.04.1) ... Creating config file /etc/php/7.0/mods-available/mysqlnd.ini with new version Creating config file /etc/php/7.0/mods-available/mysqli.ini with new version Creating config file /etc/php/7.0/mods-available/pdo_mysql.ini with new version Setting up php-mysql (1:7.0+35ubuntu6.1) ... Processing triggers for libapache2-mod-php7.0 (7.0.30-0ubuntu0.16.04.1) ... Processing triggers for php7.0-fpm (7.0.30-0ubuntu0.16.04.1) ... ⚡ root@NanoPi-NEO2 /etc/php/7.0/apache2 ⚡ root@NanoPi-NEO2 /etc/php/7.0/apache2 service apache2 restart ⚡ root@NanoPi-NEO2 /etc/php/7.0/apache2 ⚡ root@NanoPi-NEO2 /etc/php/7.0/apache2 php -m [PHP Modules] calendar Core ctype date exif fileinfo filter ftp gettext hash iconv json libxml mysqli mysqlnd openssl pcntl pcre PDO pdo_mysql Phar posix readline Reflection session shmop sockets SPL standard sysvmsg sysvsem sysvshm tokenizer Zend OPcache zlib [Zend Modules] Zend OPcache