duanmajing9332
2016-02-16 06:06
浏览 623
已采纳

如何在php 7中启用MySQLi扩展?

I have installed PHP 7, MySQL 5.5.47 on Ubuntu 14.04. I have checked installed extension using :

sudo apt-cache search php7-*

Its output me:

php7.0-common - Common files for packages built from the PHP source
libapache2-mod-php7.0 - server-side, HTML-embedded scripting language (Apache 2 module)
php7.0-cgi - server-side, HTML-embedded scripting language (CGI binary)
php7.0-cli - command-line interpreter for the PHP scripting language
php7.0-phpdbg - server-side, HTML-embedded scripting language (PHPDBG binary)
php7.0-fpm - server-side, HTML-embedded scripting language (FPM-CGI binary)
libphp7.0-embed - HTML-embedded scripting language (Embedded SAPI library)
php7.0-dev - Files for PHP7.0 module development
php7.0-dbg - Debug symbols for PHP7.0
php7.0-curl - CURL module for PHP
php7.0-enchant - Enchant module for PHP
php7.0-gd - GD module for PHP
php7.0-gmp - GMP module for PHP
php7.0-imap - IMAP module for PHP
php7.0-interbase - Interbase module for PHP
php7.0-intl - Internationalisation module for PHP
php7.0-ldap - LDAP module for PHP
php7.0-mcrypt - libmcrypt module for PHP
php7.0-readline - readline module for PHP
php7.0-odbc - ODBC module for PHP
php7.0-pgsql - PostgreSQL module for PHP
php7.0-pspell - pspell module for PHP
php7.0-recode - recode module for PHP
php7.0-snmp - SNMP module for PHP
php7.0-tidy - tidy module for PHP
php7.0-xmlrpc - XMLRPC-EPI module for PHP
php7.0-xsl - XSL module for PHP
php7.0 - server-side, HTML-embedded scripting language (metapackage)
php7.0-json - JSON module for PHP
php-all-dev - package depending on all supported PHP development packages
php7.0-sybase - Sybase module for PHP
php7.0-sqlite3 - SQLite3 module for PHP
php7.0-mysql - MySQL module for PHP
php7.0-opcache - Zend OpCache module for PHP
php7.0-bz2 - bzip2 module for PHP

I am not able to see MySQLi extension using phpinfo() as well,please let me know,how can I enable/install MySQLi extension in PHP 7. That's why I cannot use phpmyadmin, its says "The mysqli extension is missing."

Note: I am new in php7.

图片转代码服务由CSDN问答提供 功能建议

我在Ubuntu 14.04上安装了PHP 7,MySQL 5.5.47。 我已经使用以下方法检查了安装的扩展名:

  sudo apt-cache search php7  -  * 
   
 
 

输出我: < pre> php7.0-common - 从PHP源构建的包的公共文件 libapache2-mod-php7.0 - 服务器端,HTML嵌入式脚本语言(Apache 2模块) php7.0-cgi - 服务器端,HTML嵌入式脚本语言(CGI二进制) php7.0-cli - PHP脚本语言的命令行解释器 php7.0-phpdbg - 服务器端,HTML嵌入式脚本语言(PHPDBG二进制) nphp7.0-fpm - 服务器端,HTML嵌入式脚本语言(FPM-CGI二进制) libphp7.0-embed - HTML嵌入式脚本语言(嵌入式SAPI库) php7.0-dev - 用于PHP7.0的文件 模块开发 php7.0-dbg - PHP7.0的调试符号 php7.0-curl - 用于PHP的CURL模块 php7.0-enchant - 用于PHP的附魔模块 php7.0-gd - 用于PHP的GD模块 php7 .0-gmp - GMP模块 e for PHP php7.0-imap - 用于PHP的IMAP模块 php7.0-interbase - 用于PHP的Interbase模块 php7.0-intl - 用于PHP的国际化模块 php7.0-ldap - 用于PHP php7的LDAP模块。 0-mcrypt - 用于PHP的libmcrypt模块 php7.0-readline - 用于PHP的readline模块 nphp7.0-odbc - 用于PHP的ODBC模块 php7.0-pgsql - 用于PHP的PostgreSQL模块 php7.0-pspell - pspell模块 for PHP php7.0-recode - 用于PHP的重新编码模块 php7.0-snmp - 用于PHP的SNMP模块 php7.0-tidy - 用于PHP的整齐模块 php7.0-xmlrpc - 用于PHP的XMLRPC-EPI模块 php7 .0-xsl - 用于PHP php7.0的XSL模块 - 服务器端,HTML嵌入式脚本语言(元数据包) php7.0-json - 用于PHP php-all-dev的JSON模块 - 包取决于所有支持的PHP 开发包 php7.0-sybase - 用于PHP的Sybase模块 php7.0-sqlite3 - 用于PHP的SQLite3模块 php7.0-mysql - 用于PHP的MySQL模块 php7.0-opcache - 用于PHP php7的Zend OpCache模块。 0-bz2 - 用于PHP的bzip2模块

我无法看到MySQLi扩展u 唱歌phpinfo(),请告诉我,如何在PHP 7中启用/安装MySQLi扩展。 这就是为什么我不能使用phpmyadmin,它说“缺少mysqli扩展名。”

注意:我是php7中的新手。

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

6条回答 默认 最新

  • douyunjiaok300404 2016-02-16 06:43
    已采纳

    I got the solution,I am able to enable MySQLi extension in php.ini, just uncommented this line in php.ini

    extension=php_mysqli.dll
    

    Now MySQLi working well.Here is php.ini file path in apache2,PHP 7, Ubuntu 14.04 environment:

    /etc/php/7.0/apache2/php.ini
    

    By Default MySQLi extension is disable in PHP 7.

    已采纳该答案
    打赏 评论
  • dpp78272 2016-02-16 07:11

    In ubuntu need to uncommented this line in php.ini which is located at /etc/php/7.0/apache2/php.ini

    extension=php_mysqli.so

    打赏 评论
  • dougu5847 2016-05-07 01:10

    The problem is that the package that used to connect PHP to MYSQL is depricated (php5-mysql). If you install the new package:

    sudo apt-get install php-mysql
    

    This will automatically update apache and php7.

    Cheers!

    打赏 评论
  • dsyrdwdbo47282676 2017-12-19 01:46
    sudo phpenmod mysqli
    sudo service apache2 restart
    

    • phpenmod moduleName enables a module to php7 (restart apache after that sudo service apache2 restart)
    • phpdismod moduleName disables a module to php7 (restart apache after that sudo service apache2 restart)
    • php -m lists the loaded modules
    打赏 评论
  • duanhai1455 2018-11-28 10:30

    Let's use

    mysqli_connect

    instead of

    mysql_connect

    because mysql_connect isn't supported in php7.

    打赏 评论
  • dongnai6973 2019-08-22 23:54

    On ubuntu,

    When mysqli is missing execute the following,

    sudo apt-get install php7.x-mysqli
    
    sudo service apache2 restart
    

    replace 7.x with your PHP version.

    note: This could be 7.0 and up, but for example Drupal recommends 'php7.2' on grounds of security a.o.

    To check your php version, on the command-line type:

    php -v
    

    You do exactly the same if you are missing mbstring

    apt-get install php7.x-mbstring
    
    service apache2 restart
    

    I recently had to do this for PHPmyadmin when upgrading php from 7.0 to 7.2 on Ubuntu 16.04 .

    打赏 评论

相关推荐 更多相似问题