php wamp 无法加载 mysqli 扩展

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/547224/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-24 23:03:18  来源:igfitidea点击:

wamp cannot load mysqli extension

phpmysqllocalhostphpmyadmin

提问by localhost

WAMP installed fine, no problems, BUT...

WAMP 安装正常,没有问题,但是...

When going to phpMyAdmin, I get the error from phpMyAdmin as follows:

转到 phpMyAdmin 时,我从 phpMyAdmin 收到错误消息,如下所示:

Cannot load mysqli extension. Please check your PHP configuration

Also, phpMyAdmin documentation explains this error message as follows:

此外,phpMyAdmin 文档解释此错误消息如下:

To connect to a MySQL server, PHP needs a set of MySQL functions called "MySQL extension". This extension may be part of the PHP distribution (compiled-in), otherwise it needs to be loaded dynamically. Its name is probably mysql.so or php_mysql.dll. phpMyAdmin tried to load the extension but failed. Usually, the problem is solved by installing a software package called "PHP-MySQL" or something similar.

要连接到 MySQL 服务器,PHP 需要一组称为“MySQL 扩展”的 MySQL 函数。此扩展可能是 PHP 发行版的一部分(已编译),否则需要动态加载。它的名字可能是 mysql.so 或 php_mysql.dll。phpMyAdmin 尝试加载扩展但失败了。通常,问题是通过安装一个名为“PHP-MySQL”或类似的软件包来解决的。

Finally, the apache_error.log file has the following PHP warnings (see the mySQL warning):

最后,apache_error.log 文件有以下 PHP 警告(请参阅 mySQL 警告):

PHP Warning: Zend Optimizer does not support this version of PHP - please upgrade to the latest version of Zend Optimizer in Unknown on line 0
PHP Warning: Zend Platform does not support this version of PHP - please upgrade to the latest version of Zend Platform in Unknown on line 0
PHP Warning: Zend Debug Server does not support this version of PHP - please upgrade to the latest version of Zend Debug Server in Unknown on line 0
PHP Warning: gd wrapper does not support this version of PHP - please upgrade to the latest version of gd wrapper in Unknown on line 0
PHP Warning: java wrapper does not support this version of PHP - please upgrade to the latest version of java wrapper in Unknown on line 0
PHP Warning: mysql wrapper does not support this version of PHP - please upgrade to the latest version of mysql wrapper in Unknown on line 0

So, for some reason PHP is not recognizing the mysql extension.

因此,出于某种原因,PHP 无法识别 mysql 扩展名。

Anyone know why? Any solution or workaround?

有谁知道为什么?任何解决方案或解决方法?

回答by Tanveer

I deleted the PHP in program files ad everything started working , the problem that there two installations of pHp

我删除了程序文件中的 PHP,一切都开始工作了,有两个 pHp 安装的问题

回答by Virendra

I tried many solutions, and none worked for me. I tried the following solutions:

我尝试了很多解决方案,但没有一个对我有用。我尝试了以下解决方案:

  • Restart wampserver
  • Reinstall wampserver
  • restart machine
  • and all other solutions mentioned in this question.
  • 重启 wampserver
  • 重新安装 wampserver
  • 重启机器
  • 以及此问题中提到的所有其他解决方案。

However, none of these worked. Then I found that my PHPMyAdmin was not working in chrome and was working in firefox. So I tried clearing cache, restarting browser etc, but still it would not work.

然而,这些都没有奏效。然后我发现我的 PHPMyAdmin 不能在 chrome 中工作,而是在 Firefox 中工作。所以我尝试清除缓存,重新启动浏览器等,但仍然无法正常工作。

Then I deleted all the files from C:\wamp\tmpand then tried again, and it works. I am not sure why it works, but here is what I think. The session was cached and not getting cleared. So as soon as I deleted all files in this directory all the sessions were deleted and hence it worked fine.

然后我删除了所有文件C:\wamp\tmp,然后再试一次,它工作正常。我不确定它为什么有效,但这是我的想法。会话被缓存并且没有被清除。所以一旦我删除了这个目录中的所有文件,所有的会话都被删除了,因此它工作正常。

回答by DeadHead

First, make sure that the php.inifile is loading the mysqliextension.
If you are using WAMPServer, click on the icon in the system tray, go to PHP-> PHP Extensionsand make sure it is checked. If not, go into the php.inifile and make sure that the line: extension=php_mysqli.dllis uncommented (eg, remove the ;if it exists). If that line does not exist, add it.

首先,确保php.ini文件正在加载mysqli扩展名。
如果您使用的是 WAMPServer,请单击系统托盘中的图标,转到PHP->PHP Extensions并确保选中它。如果没有,进入php.ini文件并确保行:extension=php_mysqli.dll未注释(例如,;如果存在,则将其删除)。如果该行不存在,请添加它。

If this still does not work, double check that the right php.inifile is being loaded.
To do so, view your phpinfo() (Herefor WAMPServer). Scroll down to the Loaded Configuration Filerow and see which php.iniis being loaded.Make sure it is the right file. If you're using WAMPServer, it should be(WAMP INSTALL FOLDER)\bin\apache\Apache2.2.11\bin\php.ini. By default, it isC:\wamp\bin\apache\Apache2.2.11\bin\php.ini`.

如果这仍然不起作用,请仔细检查php.ini是否正在加载正确的文件。
为此,请查看您的 phpinfo()(此处为 WAMPServer)。向下滚动到该Loaded Configuration File行并查看php.ini正在加载的内容。Make sure it is the right file. If you're using WAMPServer, it should be(WAMP 安装文件夹)\bin\apache\Apache2.2.11\bin\php.ini . By default, it isC:\wamp\bin\apache\Apache2.2.11\bin\php.ini`。

If a different php.inifile is being loaded, just rename it to something else so that PHP will try and find the file somewhere else. There should be a way to specify which on eyou want to use, but I forget exactly how to do that...

如果php.ini正在加载不同的文件,只需将其重命名为其他名称,以便 PHP 尝试在其他位置找到该文件。应该有一种方法可以指定您要使用哪个,但我忘记了确切的方法...

If this still doesn't work... Try messing around with phpMyAdmin's settings, or using another answer, but I'm afraid I can't help beyond this.

如果这仍然不起作用...尝试弄乱 phpMyAdmin 的设置,或使用其他答案,但恐怕我无能为力。

回答by rafaelcarioca7

Just add in your php.ini:

只需在你的 php.ini 添加:

[PHP_MCRYPT]
extension=php_mcrypt.dll
[PHP_MYSQL]
extension=php_mysql.dll
[PHP_MYSQLI]
extension=php_mysqli.dll

回答by mr.m

Also setup the mysql password:

还要设置mysql密码:

SET PASSWORD FOR root@localhost=PASSWORD('your_password');

And the phpmyadmin mysql password in config.inc.php:

以及 config.inc.php 中的 phpmyadmin mysql 密码:

$cfg['Servers'][$i]['password'] = 'your_password';

回答by Vicer

I had the same problem. I had WAMP server installed. All was working fine. Then one day I restarted my computer and it just stopped working! I tried desperately going through all help posts and doing them but nothing worked.

我有同样的问题。我安装了 WAMP 服务器。一切正常。然后有一天我重新启动了我的电脑,它就停止工作了!我拼命浏览所有帮助帖子并执行它们,但没有任何效果。

What they usually suggest you do is, first go to your php.ini file and make sure your 'extension_dir' is properly set. Then to make sure these two lines are not commented (remove the ; infront): extension=php_mysql.dll extension=php_mysqli.dll

他们通常建议您做的是,首先转到您的 php.ini 文件并确保您的“extension_dir”设置正确。然后确保这两行没有被注释(去掉前面的 ;): extension=php_mysql.dll extension=php_mysqli.dll

Then some suggested that I download fresh copies of these two files but none worked. I also tried uninstalling everything (php/mysql/apache) and reinstalled fresh copies of WAMP server several times but with no luck.

然后有人建议我下载这两个文件的新副本,但没有任何效果。我还尝试卸载所有内容(php/mysql/apache)并多次重新安装 WAMP 服务器的新副本,但没有成功。

Finally I managed to find an alternative solution. I switched to 'easyphp' (http://www.easyphp.org/). This is something very similar to WAMP. First I made backups of my sql databases so I can reload them on the new installation.

最后我设法找到了替代解决方案。我切换到“easyphp”(http://www.easyphp.org/)。这与 WAMP 非常相似。首先,我备份了我的 sql 数据库,以便我可以在新安装中重新加载它们。

Then I installed 'easyphp' and everything seems to work fine. I reloaded my sql databases from my backup and now things are back to normal.

然后我安装了“easyphp”,一切似乎都正常。我从备份中重新加载了我的 sql 数据库,现在一切恢复正常。

I hope someone suffering from a similar prob. will find this useful. If someone has really found a fix to make WAMP server work. Pls do be kind enough to post it here so many will benefit.

我希望有人患有类似的问题。会发现这很有用。如果有人真的找到了使 WAMP 服务器正常工作的修复程序。请不要把它张贴在这里,所以很多人都会受益。

回答by Arti Lamba

in wampserver go to php.ini. open the file and uncomment extension=msql.dll by removing semicolon(;) for respective operating sytem.

在 wampserver 中转到 php.ini。通过删除相应操作系统的分号(;)打开文件并取消注释 extension=msql.dll。

回答by Vikrant Ramteke

I was running WAMP with two PHP versions 1) 5.2.9 and 2) 5.2.13.

我使用两个 PHP 版本 1) 5.2.9 和 2) 5.2.13 运行 WAMP。

As per site requirement i needed to change PHP version to 5.2.9 from 5.2.13. after swapping PHP version, error was "mysqli extension is missing". after debugging long time i get to know it was due to wrong "extension_dir" path in php.ini file.

根据站点要求,我需要将 PHP 版本从 5.2.13 更改为 5.2.9。交换 PHP 版本后,错误是“缺少 mysqli 扩展”。经过长时间的调试,我知道这是由于 php.ini 文件中的“extension_dir”路径错误造成的。

So i changed its value:

所以我改变了它的价值:

Old: "extension_dir" c:/wamp/bin/php/php5.2.13/ext/

旧:“extension_dir” c:/wamp/bin/php/php5.2.13/ext/

New: "extension_dir" c:/wamp/bin/php/php5.2.9/ext/

新:“extension_dir” c:/wamp/bin/php/php5.2.9/ext/

Restarted All services in wamp server, then it's fixed.

重新启动 wamp 服务器中的所有服务,然后它就修复了。

回答by Andrew

I had path variable in windows set to some random version of php.

我将 Windows 中的路径变量设置为某个随机版本的 php。

The fix was to update it and set it to the folder within my wampserver installation:

修复是更新它并将其设置为我的 wampserver 安装中的文件夹:

C:\wamp64\bin\php\php5.6.38

Then I realized this is wrong also for my specific case, and I should actually be running the script from within vagrant. Live and learn.

然后我意识到这对于我的特定情况也是错误的,我实际上应该从 vagrant 中运行脚本。活到老,学到老。

回答by Sajeev

I had this issue because of a different reason:

由于不同的原因,我遇到了这个问题:

Check the PHP Error Log(Get from the Wamp Tray -> PHP -> PHP Error Log. I had a syntax error in the php.ini file while I was editing the file. Check the log and clear the error. This will open your PhpMyAdmin properly.

检查 PHP 错误日志(从 Wamp 托盘获取 -> PHP -> PHP 错误日志。我在编辑文件时在 php.ini 文件中出现语法错误。检查日志并清除错误。这将打开您的PhpMyAdmin 正确。