array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'zh', ), 'this' => array ( 0 => 'mysqli.requirements.php', 1 => '需求', ), 'up' => array ( 0 => 'mysqli.setup.php', 1 => '安装/配置', ), 'prev' => array ( 0 => 'mysqli.setup.php', 1 => '安装/配置', ), 'next' => array ( 0 => 'mysqli.installation.php', 1 => '安装', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'zh', 'path' => 'reference/mysqli/setup.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
为了使这些函数可用,必须编译支持 mysqli 扩展的 PHP。
MySQL 8
当运行 PHP 7.1.16 之前的版本或者 PHP 7.2.4 之前的 PHP 7.2 版本时,需要将 MySQL 8 服务器的默认密码插件设置为 mysql_native_password。否则在未使用 caching_sha2_password 时,也会看到类似这样的错误 The server requested authentication method unknown to the client [caching_sha2_password]。
这是因为 MySQL 8 默认使用 caching_sha2_password,这是旧版 PHP (mysqlnd) 版本无法识别的插件。然而,可以在
my.cnf 中设置 default_authentication_plugin=mysql_native_password
来变更它。从 PHP 7.4.4 开始,完全支持 caching_sha2_password
插件。对于旧版本,mysql_xdevapi 扩展支持。