php 如何在 MacOS 上安装 MySQLi

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

How to install MySQLi on MacOS

phpmacosmysqli

提问by Hyman Humphries

I cannot find instructions about installing MySQLi on a Mac. Just to be clear, MySQL is up to date and I am running PHP 5. How do I install it? Where do I even get it from? Thanks for your help. I'll be giving an up vote and a check mark to whoever answers this!

我找不到有关在 Mac 上安装 MySQLi 的说明。需要说明的是,MySQL 是最新的,我运行的是 PHP 5。我该如何安装它?我从哪里得到它?谢谢你的帮助。我将给回答这个问题的人投赞成票和一个复选标记!

采纳答案by Marc B

MySQLi is part of PHP. There should be a php-mysqli type package available, or you can take the PHP source and recompile that mysqli enabled. You may already have it installed, but it's done as a module and is disabled. Check your php.ini for extension=mysqli.soor similar. it may be commented out, or the .so file is present in your extensions directory but not linked to PHP via that extension= directive.

MySQLi 是 PHP 的一部分。应该有一个 php-mysqli 类型的包可用,或者您可以使用 PHP 源代码并重新编译启用了 mysqli 的包。您可能已经安装了它,但它是作为一个模块完成的并且被禁用。检查您的 php.iniextension=mysqli.so或类似内容。它可能被注释掉,或者 .so 文件存在于您的扩展目录中,但未通过该 extension= 指令链接到 PHP。

回答by Aldo Solis Zenteno

Use php-mysqlndinstead of php-mysql. On Linux, to install with apt-gettype:

使用php-mysqlnd代替php-mysql。在 Linux 上,使用apt-get类型安装:

apt-get install php-mysqlnd

回答by Dulitha Kumarasiri

This article is clearly explained, how to install MySqli with EachApache. This works for me too.

这篇文章讲解的很清楚,如何用EachApache安装MySqli。这也适用于我。

To install mysqli using EachApache:

使用 EachApache 安装 mysqli:

  1. Login to WHM as 'root' user.

  2. Either search for "EasyApache" or go to Software > EasyApache

  3. Scroll down and select a build option (Previously Saved Config)

  4. Click Start "Start customizing based on profile"

  5. Select the version of Apache and click "Next Step".

  6. Select the version of PHP and click "Next Step".

  7. Chose additional options within the "Short Options List"

  8. Select "Exhaustive Options List" and look for "MySQL Improved extension"

  9. Click "Save and Build"

  1. 以“root”用户身份登录 WHM。

  2. 搜索“EasyApache”或转到“软件”>“EasyApache”

  3. 向下滚动并选择一个构建选项(以前保存的配置)

  4. 单击开始“开始根据配置文件进行自定义”

  5. 选择Apache的版本,然后单击“下一步”。

  6. 选择 PHP 版本,然后单击“下一步”。

  7. 在“简短选项列表”中选择其他选项

  8. 选择“详尽的选项列表”并查找“MySQL改进的扩展”

  9. 点击“保存并构建”

回答by Ajeet Shah

This is how I installed it on my Debian based machine (ubuntu):

这是我在基于 Debian 的机器 (ubuntu) 上安装它的方式:

php 7:

php 7:

sudo apt-get install php7.0-mysqli

php 5:

php 5:

sudo apt-get install php5-mysqli

回答by Marcos Vinícius Soares

You are supposed to edit twolines in your php.ini file (i'm using windows for this example):

你应该在你的 php.ini 文件中编辑行(我在这个例子中使用的是 windows):

-The first one is regarding the extensions directory location. See below:

- 第一个是关于扩展目录位置。见下文:

; Directory in which the loadable extensions (modules) reside.
; http://php.net/extension-dir
; extension_dir = "./"
; On windows:
extension_dir = "C:/php/ext"

-The second one is regarding the extension itself:

- 第二个是关于扩展本身:

extension=php_mysqli.dll

Only modifying (uncommenting) the extension line was not enough for me. Hope it helps

仅修改(取消注释)延长线对我来说是不够的。希望能帮助到你

回答by Shambhu

For windows: 3 steps

对于窗户:3 个步骤

step1: Just need to give the extfolder path in php.ini

step1:只需要给出ext文件夹路径php.ini

here

这里

; Directory in which the loadable extensions (modules) reside.
; http://php.net/extension-dir
; extension_dir = "./"
; On windows:
 extension_dir = "C:\php7\ext"

step 2: Remove the comment from

第 2 步:删除评论

extension=php_mysqli.dll

step 3: restart the Apache server.

第三步:重启Apache服务器。

Happy coding!!!

快乐编码!!!

回答by Kleo M. Zane

Here is the link for installation details: http://php.net/manual/en/mysqli.installation.php

这是安装详细信息的链接:http: //php.net/manual/en/mysqli.installation.php

If you are using Windowsor Linux:
- The MySQLi extension is automatically installed in most cases, when PHP & MySQL package is installed.

如果您使用的是WindowsLinux
- 在大多数情况下,MySQLi 扩展会在安装 PHP 和 MySQL 包时自动安装。

回答by Juergen

sudo apt-get -y -f install php7.0-mysql

回答by Julian Gong

Since you are using a Mac, open a terminal, and

由于您使用的是 Mac,打开终端,然后

  • cd /etc
  • 光盘 / 等

Find the php.ini, and sudo open it, for example, using the nano editor

找到php.ini,sudo打开,例如使用nano编辑器

  • nano php.ini
  • 纳米php.ini

Find use control+w to search for "mysqli.default_socket", and change the line to

找到使用 control+w 搜索“mysqli.default_socket”,将这一行改为

  • mysqli.default_socket = /tmp/mysql.sock
  • mysqli.default_socket = /tmp/mysql.sock

Use control+x and then hit "y" and "return" to save the file. Restart Aapche if necessary.

使用 control+x 然后点击“y”和“return”来保存文件。如有必要,重新启动 Aapche。

Now you should be able to run mysqli.

现在您应该能够运行 mysqli。

回答by Rich

I recently ditched Xampp in favor of the native Apache on Mac Sierra because a new php requirement of a project. Sierra comes with php 5.6.25, but it doesn't run mysql_* out of the box, after a lot of googling, I found this site really help - https://php-osx.liip.ch. As it turns out php 5.6.25 does support mysql_* but wasn't enabled. Choose your version of php and download it, it generates a proper php.ini for your php, then you are good to go

我最近放弃了 Xampp,转而使用 Mac Sierra 上的本机 Apache,因为项目的新 php 要求。Sierra 带有 php 5.6.25,但它并没有开箱即用地运行 mysql_*,经过大量的谷歌搜索,我发现这个站点真的很有帮助 - https://php-osx.liip.ch。事实证明 php 5.6.25 确实支持 mysql_* 但没有启用。选择你的php版本并下载它,它会为你的php生成一个合适的php.ini,然后你就可以开始了