macos PHP 和“打开”mysqli

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1460167/
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-10-21 06:25:35  来源:igfitidea点击:

PHP and "turning on" mysqli

phpmacosmysqli

提问by Anthony

I'm having trouble finding documentation about how exactly to go about "turning on" mysqli. I'm running OS X SL and, as I understand it, since php5 is installed, the mysqli extension should already be there as well.

我很难找到有关如何“打开”mysqli 的文档。我正在运行 OS X SL,据我所知,由于安装了 php5,mysqli 扩展也应该已经存在。

Is this as simple as adding a LoadModule line to php.ini? If I need to re-compile php, does anyone know of a good link where I could follow along to do that (so I don't goof anything up)?

这与向 php.ini 添加 LoadModule 行一样简单吗?如果我需要重新编译 php,有没有人知道一个很好的链接,我可以跟着做(所以我不会搞砸任何事情)?

Thanks in advance.

提前致谢。

回答by Bj?rn

PHP.net said:

PHP.net 说

As of PHP 5.0, MySQL support is no longer enabled by default with the standard PHP distributions.

从 PHP 5.0 开始,标准 PHP 发行版不再默认启用 MySQL 支持。

You will need to configure PHP with MySQLi-support. Why don't take the safe (and probably best), object oriented, road and go with the PDOclasses?

您需要使用 MySQLi 支持配置 PHP。为什么不采取安全的(可能是最好的)、面向对象的道路并使用PDO类呢?

回答by Asaph

Save yourself the headache and install the entropy PHP packageor MAMP. Getting all the commonly needed PHP modules working on OSX is non-trivial. Most people I know go with either one of those packages.

省去头疼的麻烦,然后安装entropy PHP 包MAMP。获取所有在 OSX 上运行的常用 PHP 模块并非易事。我认识的大多数人都使用这些软件包中的任何一个。

Update:

更新:

A lot has changed since I originally posted this answer. These days, the most straight forward thing to do on OSX is to use Homebrew.

自从我最初发布此答案以来发生了很多变化。如今,在 OSX 上最直接的做法是使用Homebrew

回答by mmattke

I was trying to install the MediaWiki on Snow Leopard with MySQL 5.1.41, which needed this as well. After plenty of stumbling around, the solution was extremely simple...

我试图用 MySQL 5.1.41 在 Snow Leopard 上安装 MediaWiki,它也需要这个。经过大量的磕磕绊绊,解决方案非常简单......

In /etc/php.ini, change the following lines from:

在 /etc/php.ini 中,更改以下行:

pdo_mysql.default_socket = /var/mysql/mysql.sock mysql.default_socket = /var/mysql/mysql.sock mysqli.default_socket = /var/mysql/mysql.sock

pdo_mysql.default_socket = /var/mysql/mysql.sock mysql.default_socket = /var/mysql/mysql.sock mysqli.default_socket = /var/mysql/mysql.sock

to: pdo_mysql.default_socket = /tmp/mysql.sock mysql.default_socket = /tmp/mysql.sock mysqli.default_socket = /tmp/mysql.sock

到: pdo_mysql.default_socket = /tmp/mysql.sock mysql.default_socket = /tmp/mysql.sock mysqli.default_socket = /tmp/mysql.sock

While I had linked /tmp/mysql.sock to /var/mysql, this didn't kick in until I actually edited the file.

虽然我已将 /tmp/mysql.sock 链接到 /var/mysql,但直到我实际编辑该文件时,它才起作用。

回答by Nick

I have had this same issue.

我也遇到过同样的问题。

You need to make sure phpMyAdmin configuration file config.inc.php has the extension pointing to mysqli not mysql which is the default.

您需要确保 phpMyAdmin 配置文件 config.inc.php 的扩展名指向 mysqli 而不是 mysql 这是默认的。

回答by Kyril

If php5 was compiled with mysqli support already, then all you should need to do is point to that library in php.ini

如果 php5 已经使用 mysqli 支持编译,那么您需要做的就是在 php.ini 中指向该库

extension=mysqli.so

After adding that you will probably need to restart apache.

添加后,您可能需要重新启动 apache。

Note:The filename for the mysqli library might differ on some platforms.

注意:mysqli 库的文件名在某些平台上可能不同。