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!
Use php-mysqlnd instead of php-mysql. On Linux, to install with apt-get type:
apt-get install php-mysqlnd
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.
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
This article is clearly explained, how to install MySqli with EachApache. This works for me too.
To install mysqli using EachApache:
Login to WHM as 'root' user.
Either search for "EasyApache" or go to Software > EasyApache
Scroll down and select a build option (Previously Saved Config)
Click Start "Start customizing based on profile"
Select the version of Apache and click "Next Step".
Select the version of PHP and click "Next Step".
Chose additional options within the "Short Options List"
Select "Exhaustive Options List" and look for "MySQL Improved extension"
Click "Save and Build"
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
Here is the link for installation details:
http://php.net/manual/en/mysqli.installation.php
If you are using Windows or Linux:
- The MySQLi extension is automatically installed in most cases, when PHP & MySQL package is installed.
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.
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.
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
sudo apt-get -y -f install php7.0-mysql
if you use ubuntu 16.04 (maybe and above) just do this
sudo phpenmod mysqli
sudo service php7.0-fpm restart
I had the same issue, I went to EasyApache4 from the WHM clicked on customize button then PHP Extension tab.. I selected and installed the extension php72-php-mysqlnd and my was solved
For mysqli on Docker's official php containers:
Tagged php versions that support mysqli may still not come with mysqli configured out of the box, You can install it with the docker-php-ext-install utility (see comment by Konstantin). This is built-in, but also available from the docker-php-extension-installer project.
They can be used to add mysqli either in a Dockerfile, for example:
FROM php:5.6.5-apache
COPY ./php.ini /usr/local/etc/php/
RUN docker-php-ext-install mysqli
or in a compose file that uses a generic php container and then injects mysqli installation as a setup step into command:
web:
image: php:5.6.5-apache
volumes:
- app:/var/www/html/
ports:
- "80:80"
command: >
sh -c "docker-php-ext-install mysqli &&
apache2-foreground"
Since many of these answers are old here is how to install mysqli for Easyapache 4.
If you try and search for mysqli under your PHP extensions in WHM you are not going to find it. The way to know which extension you need to install mysqli you will need to run this command in terminal
repoquery -q --whatprovides 'ea-php70-php-mysqli' | sort -V | tail -1
Should return something like
ea-php70-php-mysqlnd-0:7.0.33-1.1.4.cpanel.x86_64
All you really need from this is mysqlnd copy it
To install mysqli using EachApache4:
Login to WHM.
Search for "EasyApache4"
At the top look for "Currently Installed Packages" and click on the button "Customize"
On the left panel click "PHP Extensions"
Search for mysqlnd
You should see something like "php70-php-mysqlnd"
Toggle the switch to enable it
On the left panel click on review
At the bottom click "Provision"
You're Done
On php 5.3.0 and later version you dont need to specially install mysqli on windows.
Rather follow simple steps as shown below.
Locate php.ini file [ if not there it means you have not copied php.ini-development or php.ini-production file as php.ini to make your configurations ]
There are 2 things to be done
1. Uncomment and set right path to extension_dir = "ext" Basically set the path where you find ext folder in php even if its in same folder from where you are running php-cgi.ex
uncomment mysqli library extention extension=mysqli
Note: uncommenting in this php.ini file is by removing starting ; from the line.
to solve this issue you should Run
sudo apt-get install php7.4-mysqli
Related
pdo is working fine with mysql but with pgsql its giving error 'PDOException' with message 'could not find driver' I've installed php5-pgsql package which also includes pdo_pgsql
http://packages.debian.org/sid/php5-pgsql
This package provides a module for PostgreSQL database connections directly from PHP scripts. It also includes the pdo_pgsql module for use with the PHP Data Object extension.
my dsn is pgsql:dbname=DB;host=192.168.0.2
I am using Ubuntu 10.04
This message means you need to install and or activate postgresql extension in PHP
This solution works for me :
To install postgresql extension
[sudo] apt-get install php-pgsql
after, for activating it, uncomment pgsql and pdo-pgsql extensions in etc/php/$PHP_VERSION/apache2/php.ini file
Finally, type :
[sudo] /etc/init.d/apache2 restart
To restart apache server if you use apache such as was my case...
1) Have you enabled pgsql.so in php.ini (extension=pgsql.so)?
2) Is you Postgresql listenin on 192.168.0.2 interface? (You can check it by netstat -tpln)
3) How you authenticate your access into Postgresql?
Make sure you've uncommented the line that tells php where the Postgres driver is (usually extension=pgsql.so) in the main php.ini file.
I had the same issue. First of all - check is it enabled in php.ini. Uncomment extension=php_pdo_pgsql...
than set up extension directory!!
extension_dir = "ext" ; for your case it could be other dir.
and do not forget to restart server after changing the config.
Try to remove semicolon in front of
extension=pgsql
extension=pgsql.so
included in your php.ini file
You can do that from the XAMPP Control Panel.
Here is what I did to solve the problem.
Edit php.ini and remove ; from extension=pdo_pgsql. Also, add extension=pgsql.so to the php.ini file.
Make sure to restart the Apache server before you try to see the result.
I had the same problem with another solution. I lost my around 4 hours to solve this problem. Please check the following to solve this problem.
Check php.ini file and remove semicolon from this line
extension=pgsql
extension=pdo_pgsql
Restart your apache2 server
sudo service apache2 restart
Check if your PDO driver has updated in localhost phpinfo()
I did All the things right and still I had this problem. And you know why? Because I had several versions of php installed. So I was running php7.4 in my php cli but localhost was running on php7.2. So always check your php versions.
Check your php version on localhost and terminal cli
When you do not have postgresql installed on the same machine that is Apache and PHP; you have to install php-pgsql and don't have to add extensions in php.ini manually in Linux (in Windows yes), because redundancies are generated and this does not work (checked in error.log).
$ sudo apt install php-pgsql
Then you can check the existence of the extension enabled automatically in:
$ sudo nano /etc/php/7.0/apache2/conf.d/10-pdo.ini
Observations: In phpinfo() you will find the directory conf.d/ and the file error.log
GL
Just run php --ini and look for Loaded Configuration File in output for the location of php.ini used by your CLI
then check you have enabled the extensions correctly.
Copy libpq.dll from the PHP directory to Apache24\bin (or wherever your installation could be).
I am trying to make postgresql work with apache on my Mac OSX. I use homebrew to manage all my dev features, so I replace the default php version provided by apache and download a homebrew version, this part works really fine. The problem is when I want to install the postgresql extension..
I have done this :
brew install postgresql
brew install php55 --with-postgresql
brew install php55-pdo-pgsql
And then edit the /etc/apache2/httpd.conf file to replace LoadModule php5_module libexec/apache2/libphp5.so by LoadModule php5_module /usr/local/opt/php55/libexec/apache2/libphp5.so.
Then when I exec the phpinfo() command, I can't see the postgresql extension installed in the PDO section. I only have this :
If anyone can help ;) Thank you all !
Possible solution :
- First install all packets like this : brew install postgresql php55 php55-pdo-pgsql
- Then brew reinstall php55 --with-postgresql
And it works.. I did this before (maybe not the same order) and it didn't work, I do not know why it works now !
Solution
When you watch the phpinfo() result, you should see something something like Loaded Configuration File and *Scan this dir for additional .ini files *. The thing is there is a global php.ini file and a .ini file per extension you install.
The value for *Scan this dir for additional .ini files * is where the .ini file for the extension must be located. So just need to create a ext-pdo_pgsql.ini and load the extension with extension="path to your/pdo_pgsql.so" (mine was /usr/local/opt/php55-pdo-pgsql/pdo_pgsql.so).
And for the installation just need brew install php55 php55-pdo-pgsql postgresql
Run php -m | grep pgsql to know if pgsql exists
Follow the example in this answer. Jump to note if you have a problem with the instruction there corresponding to number 4 here.
Enter ./configure --with-pdo-pgsql="path to postgres" and return. Mine is at "/usr/local/bin".
Enter make && sudo make install and return.
Add the extension to php.ini with sudo echo "extension=pdo_pgsql.so" >> path to php.ini. Find the path using php -i | grep php.ini
That should install pdo driver for postgres
Note
It is possible that sudo make install doesn't work. It might be due to an OSX feature known as csrutil. Reboot your machine and hold down cmd + R. From the recovery inteface run csrutil disable from terminal.
Reboot again and perform the make install. Repeat same process as in the paragraph above to enable csrutil by running csrutil enable at the recovery interface's terminal.
I'm using XAMPP for Windows and decided to try out Symfony 2.
As soon as I get to Symfony Configuration page it recommends me to install and enable intl.
I tried reading PEAR's and PECL's guides, since I'm total 0 on this topic(started learning PHP recently), but nothing worked.
I found php_intl.dll inside my C:\xamp\php\ext. The php.ini's extension_dir= is set to "C:\xampp\php\ext". I was only missing the extension=php_intl.dll inside php.ini, so I added it.
Unfortunately it didn't work, and Symfony keeps asking me for intl.
Whenever you make changes to php.ini, remember to restart Apache. Otherwise the changes won't take effect. You can do this in the XAMPP Control Panel by clicking the stop/start button in the Apache module row.
http://php.net/manual/en/intl.requirements.php
This extension is bundled with PHP as of PHP version 5.3.0.
Alternatively, the PECL version of this extension may be used with all
PHP versions greater than 5.2.0 (5.2.4+ recommended).
also read my comment to your post above
Follow these steps:
Copy all the file names starting with "icu" from C:\wamp\bin\php\php5.5.12 and paste to C:\wamp\bin\apache\apache2.4.9\bin (I am using WAMP. Figure it out yourself for XAMP.)
You can try. Nothing will harm. If you feel the things are not working, you can delete them. I am sure it will work for you 100%.
Uncomment the following line on C:\wamp\bin\apache\apache2.4.9\bin\php.ini
extension=php_intl.dll
It will work.
For Linux users:
Installing php5-intl made it work for me
sudo apt-get install php5-intl
found here:
http://www.php.net/manual/en/intl.setup.php
For OS X users:
1.Normally, the PHP is automatically installed on OSX. So, if you would like to use the XAMPP, or whatever apache server, you must change the path point to XAMPP. You can check the path by using:
$ which php
(do not copy $ sign, it means than you should type this in Terminal, not php)
You should get: /Applications/XAMPP/xamppfiles/bin/php ,
if not, you will get /usr/bin/php.
This is OSX' php. So, you have to change it to XAMPP' php by using:
$ PATH="/Applications/XAMPP/xamppfiles/bin:${PATH}"
2.Run this command to download, unpack, compile and install ICU (you can choose different version is your Symfony required):
$ curl -sS -o /tmp/icu.tar.gz -L http://download.icu-project.org/files/icu4c/57.1/icu4c-57_1-src.tgz && tar -zxf /tmp/icu.tar.gz -C /tmp && cd /tmp/icu/source && ./configure --prefix=/usr/local && make && sudo make install
than run:
$ sudo pecl install intl
and specify where ICU libraries and headers can be found [DEFAULT] :
/usr/local
Pay attention to information in install report:
You should add "extension=intl.so" to php.ini
Don't forget to reboot Apache and check version:
<?php
if (extension_loaded('intl')) {
echo "PHP: " . PHP_VERSION . "<br>\n";
echo "ICU: " . INTL_ICU_VERSION . "<br>\n";
} else {
die('OOPS! The intl extension is not enabled!');
}
Partially taken from here but modified to get success Install PHP Internationalization extension (Intl) on XAMPP on Mac
To activate this extension in Xampp, just edit your php.ini (i.e. in C:\xampp\php directory) and remove the semicolon to uncomment this line :
;extension=php_intl.dll
Eventually don’t forget to restart Apache !
To solve this go to "c:\xampp\php\php.ini" open it in your editor and search for Dynamic Extensions then go down search for ;extension=php_intl.dll and enable it(remove ; to became like ) extension=php_intl.dll after that save your file php.ini and restart your localhost
I installed everything separately (Apache, PHP, MySQL and phpMyAdmin) and do not use a compilation, everything works fine till now except phpMyAdmin.
The problem I am experiencing is, that the error message states that the "MySQL extension is missing", as soon as I try to call up:
localhost/phpmyadmin/index.php
And when I call up
localhost/phpmyadmin/setup/index.php
I have two messages where I do not know if it is supposed to be like that:
Bzip2 compression and decompression requires functions (bzopen,
bzcompress) which are unavailable on this system.
and:
Zip decompression requires functions (zip_open) which are unavailable
on this system.
Any suggestions?
At first make sure you have mysql installed properly. You can ensure it just by checking that whether you can access mysql using mysql command promp. So if you mysql is working then probably it is not loading. For that follow the steps given below
First of all, you must find your php.ini. It could be anywhere but if you create a small php file with the
<?php phpinfo(); ?>
script it will tell you where it is. Just look at the path of loaded configuration file.
Common places include /etc/apache/, /etc/php4/apache2/php.ini, /etc/php5/apache2/php.ini or even /usr/local/lib/php.ini for Windows it may be C:\Users\username\PHP\php.ini
Edit your server’s php.ini and look for the following line. Remove the ‘;’ from the start of the line and restart Apache. Things should work fine now!
;extension=mysql.so
should become
extension=mysql.so
For windows it will be
;extension=mysql.dll
should become
extension=mysql.dll
Some linux distributions have a php_mysql and php_mysqli package to install.
You need to put the full path in the php ini when loading the mysql dll, i.e :-
extension=c:/php54/ext/php_mbstring.dll
extension=c:/php54/ext/php_mysql.dll
Then you don't need to move them to the windows folder.
In my case I had to install the extension:
yum install php php-mysql httpd
and then restart apache:
service httpd restart
That solved the problem.
Just as others stated you need to remove the ';' from:
;extension=php_mysql.dll and
;extension=php_mysqli.dll
in your php.ini to enable mysql and mysqli extensions. But MOST IMPORTANT of all, you should set the extension_dir in your php.ini to point to your extensions directory. The default most of the time is "ext". You should change it to the absolute path to the extensions folder. i.e. if you have your xampp installed on drive C, then C:/xampp/php/ext is the absolute path to the ext folder, and It should work like a charm!
I just add
apt-get install php5-mysqlnd
This will ask to overwrite mysql.so from "php5-mysql".
This work for me.
Installing bzip2 and zip PHP extensions solved my issue in Ubuntu:
sudo apt-get install php7.0-bz2
sudo apt-get install php7.0-zip
Use php(you version)-(extension) to install and enable any missing modules that is required in the phpmyadmin readme.
Your installation is missing some php modules, there should be a list of required modules in the phpmyadmin readme. If you recently enabled the modules, try restarting the apache service / daemon.
Edit: As it seems, there is no single "enable these modules" in the docs, so enable either mysql or mysqli in your php.ini (you might need to install it first).
The two messages are not important if you do not intend to upload or download compressed file within phpMyAdmin. If you do, enable the zlib and / or bz2 modules.
I had a similar issue, but it didn't help to add extension=mysql.so in my php.ini. It turned out that the mysql.so file was not in my extension folder nor anywhere else on my machine. Solved this by downloading the php source and building the extension manually and then copying it into the extension folder.
Just check your php.ini file, In this file Semicolon(;) used for comment
if you see then remove semicolon ;.
;extension=mysql.dll
Now your extension is enable but you need to restart appache
extension=mysql.dll
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!
Use php-mysqlnd instead of php-mysql. On Linux, to install with apt-get type:
apt-get install php-mysqlnd
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.
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
This article is clearly explained, how to install MySqli with EachApache. This works for me too.
To install mysqli using EachApache:
Login to WHM as 'root' user.
Either search for "EasyApache" or go to Software > EasyApache
Scroll down and select a build option (Previously Saved Config)
Click Start "Start customizing based on profile"
Select the version of Apache and click "Next Step".
Select the version of PHP and click "Next Step".
Chose additional options within the "Short Options List"
Select "Exhaustive Options List" and look for "MySQL Improved extension"
Click "Save and Build"
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
Here is the link for installation details:
http://php.net/manual/en/mysqli.installation.php
If you are using Windows or Linux:
- The MySQLi extension is automatically installed in most cases, when PHP & MySQL package is installed.
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.
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.
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
sudo apt-get -y -f install php7.0-mysql
if you use ubuntu 16.04 (maybe and above) just do this
sudo phpenmod mysqli
sudo service php7.0-fpm restart
I had the same issue, I went to EasyApache4 from the WHM clicked on customize button then PHP Extension tab.. I selected and installed the extension php72-php-mysqlnd and my was solved
For mysqli on Docker's official php containers:
Tagged php versions that support mysqli may still not come with mysqli configured out of the box, You can install it with the docker-php-ext-install utility (see comment by Konstantin). This is built-in, but also available from the docker-php-extension-installer project.
They can be used to add mysqli either in a Dockerfile, for example:
FROM php:5.6.5-apache
COPY ./php.ini /usr/local/etc/php/
RUN docker-php-ext-install mysqli
or in a compose file that uses a generic php container and then injects mysqli installation as a setup step into command:
web:
image: php:5.6.5-apache
volumes:
- app:/var/www/html/
ports:
- "80:80"
command: >
sh -c "docker-php-ext-install mysqli &&
apache2-foreground"
Since many of these answers are old here is how to install mysqli for Easyapache 4.
If you try and search for mysqli under your PHP extensions in WHM you are not going to find it. The way to know which extension you need to install mysqli you will need to run this command in terminal
repoquery -q --whatprovides 'ea-php70-php-mysqli' | sort -V | tail -1
Should return something like
ea-php70-php-mysqlnd-0:7.0.33-1.1.4.cpanel.x86_64
All you really need from this is mysqlnd copy it
To install mysqli using EachApache4:
Login to WHM.
Search for "EasyApache4"
At the top look for "Currently Installed Packages" and click on the button "Customize"
On the left panel click "PHP Extensions"
Search for mysqlnd
You should see something like "php70-php-mysqlnd"
Toggle the switch to enable it
On the left panel click on review
At the bottom click "Provision"
You're Done
On php 5.3.0 and later version you dont need to specially install mysqli on windows.
Rather follow simple steps as shown below.
Locate php.ini file [ if not there it means you have not copied php.ini-development or php.ini-production file as php.ini to make your configurations ]
There are 2 things to be done
1. Uncomment and set right path to extension_dir = "ext" Basically set the path where you find ext folder in php even if its in same folder from where you are running php-cgi.ex
uncomment mysqli library extention extension=mysqli
Note: uncommenting in this php.ini file is by removing starting ; from the line.
to solve this issue you should Run
sudo apt-get install php7.4-mysqli