How to install MySQLi

2019-01-02 21:25发布

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!

11条回答
大哥的爱人
2楼-- · 2019-01-02 21:37

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.so or 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.

查看更多
流年柔荑漫光年
3楼-- · 2019-01-02 21:40

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

-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

查看更多
萌妹纸的霸气范
4楼-- · 2019-01-02 21:40

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

  • cd /etc

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

  • nano php.ini

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

  • mysqli.default_socket = /tmp/mysql.sock

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

Now you should be able to run mysqli.

查看更多
后来的你喜欢了谁
5楼-- · 2019-01-02 21:43

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

查看更多
一个人的天荒地老
6楼-- · 2019-01-02 21:50

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

php 7:

sudo apt-get install php7.0-mysqli

php 5:

sudo apt-get install php5-mysqli
查看更多
牵手、夕阳
7楼-- · 2019-01-02 21:50

For windows: 3 steps

step1: Just need to give the ext folder path in 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

extension=php_mysqli.dll

step 3: restart the Apache server.

Happy coding!!!

查看更多
登录 后发表回答