Linux php pdo install

PHP 7 RC3: How to install missing MySQL PDO

I am trying to setup webserver with PHP 7 RC3 + Nginx on Ubuntu 14.04 (for test purposes). I installed Ubuntu in Vagrant using ubuntu/trusty64 and PHP 7 RC 3 from Ondřej Surý (https://launchpad.net/~ondrej/+archive/ubuntu/php-7.0). I can not find the way to install MySQL PDO (PHP sees PDO class but not anything related to MySQL, like PDO::MYSQL_ATTR_DIRECT_QUERY etc.) Looks like there is no lib php7.0-mysql (by analogy with standard php5-mysqlnd and php7.0-fpm etc. from Ondřej) Section PDO in phpinfo() :

PDO support enabled PDO drivers no value 

You say Ubuntu 12.04, but then that you’re using ubuntu/trusty64 which is 14.04. Assuming that you are in fact using Trusty (after all, Ondřej hasn’t produced packages for Precise) then his php-modules package will provide php-mysql .

Yes, you are absolutely right! (version is fixed). And your suggestion with module name works. Thanks! If you add it as answer I will mark it as correct.

My mistake — i was searching like this apt-cache search php pdo and module php-mysql in this case is not shown.

If it’s anything like standard Ubuntu/Debian you can also install php5-mysqlnd to use the mysql native driver, which according to that link is «strongly encouraged», even if the Ubuntu devs don’t use it by default.

13 Answers 13

For thoses running Linux with apache2 you need to install php-mysql

or if you are running ubuntu 16.04 or higher just running the following command will be enought, no need to edit your php.ini file

apt-get install php7.2-mysql 

If you are running ubuntu 15.10 or below:

Edit your php.ini file, it’s located at /etc/php/[version]/apache2/php.ini and search for pdo_mysql you might found something like this

Save the file and restart apache

Check that it’s available in your phpinfo()

Just a general FYI, I would highly recommend using MySQLND( php-mysqlnd ) instead of the older php-mysql package

Not everyone has the luxury of choosing what library the customer app is already using, and not everyone can just «apt-get»

Читайте также:  Изменение hostname astra linux

Note: «service restart apache2» should read «service apache2 restart». For Ubuntu 16.04 I used only «sudo apt-get install php7.0-mysql» and «sudo service apache2 restart».

sudo apt-get install php7.0-mysql //change the version number based on the php version 
sudo service apache2 restart 

On ubuntu 18.04 following works for me

type this in your terminal

sudo apt-get install php7.3-gd php7.3-mysql 
sudo apt-get install php7.0-gd php7.0-mysql 
sudo apt-get install php5-gd php5-mysql 

Since eggyal didn’t provided his comment as answer after he gave right advice in a comment — i am posting it here: In my case I had to install module php-mysql . See comments under the question for details.

First, check if your php.ini has the extension enabled «php_pdo_mysql» and «php_mysqli» and the path of «extension_dir» is correct. If you need one of above configuration, then, you must restart the php-fpm to apply the changes.

In my case (where i am using the Windows OS in the company, i really prefer OSX or Linux), i solved the problem putting this values in the php.ini:

; . extension_dir = "ext" ; . extension=php_mysqli.dll extension=php_pdo_mysql.dll ; . 

If you are on windows, and your php folder is not in your PATH, you have set the absolute directory in your php.ini

extension=php_mysqli.dll extension=php_pdo_mysql.dll 

Restart apache2.4 and it should work.

  1. download the source code of php 7 and extract it.
  2. open your terminal
  3. swim to the ext/mysqli directory
  4. use commands:

Thanks, the same worked for pdo_mysql. Not sure why it isn’t compiled as part of default make;make install o_O

I had, pretty much, the same problem. I was able to see that PDO was enabled but I had no available drivers (using PHP 7-RC4). I managed to resolve the issue by adding the php_pdo_mysql extension to those which were enabled.

I resolved my problem on ubunto 20.4 by reinstalling php-mysql.

sudo apt purge php7.2-mysql 
sudo apt install php7.2-mysql 

It will add new configurations in php.ini

Had the same issue, resolved by actually enabling the extension in the php.ini with the right file name. It was listed as php_pdo_mysql.so but the module name in /lib/php/modules was called just pdo_mysql.so

Читайте также:  Полный бэкап linux centos

So just remove the «php_» prefix from the php.ini file and then restart the httpd service and it worked like a charm.

Please note that I’m using Arch and thus path names and services may be different depending on your distrubution.

I’ll start with the answer then context NOTE this fix was logged above, I’m just re-stating it for anyone googling.

  1. Download the source code of php 7 and extract it.
  2. open your terminal
  3. swim to the ext/pdo_mysql directory
  4. use commands: phpize ./configure make make install (as root)
  5. enable extension=mysqli.so in your php.ini file

This is logged as an answer from here (please upvote it if it helped you too): https://stackoverflow.com/a/39277373/3912517

Context: I’m trying to add LimeSurvey to the standard WordPress Docker. The single point holding me back is «PHP PDO driver library» which is «None found»

php -i | grep PDO PHP Warning: PHP Startup: Unable to load dynamic library 'pdo_odbc' (tried: /usr/local/lib/php/extensions/no-debug-non-zts-20170718/pdo_odbc (/usr/local/lib/php/extensions/no-debug-non-zts-20170718/pdo_odbc: cannot open shared object file: No such file or directory), /usr/local/lib/php/extensions/no-debug-non-zts-20170718/pdo_odbc.so (/usr/local/lib/php/extensions/no-debug-non-zts-20170718/pdo_odbc.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 PHP Warning: Module 'mysqli' already loaded in Unknown on line 0 PDO PDO support => enabled PDO drivers => sqlite PDO Driver for SQLite 3.x => enabled 
apt-get install php7.0-mysql 
Package 'php7.0-mysql' has no installation candidate 

Get instructions saying all I have to do is run this:

add-apt-repository -y ppa:ondrej/apache2 
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc5 in position 223: ordinal not in range(128) 

So I try and force some type of UTF: LC_ALL=C.UTF-8 add-apt-repository -y ppa:ondrej/apache2 and I get this: no valid OpenPGP data found.

Follow some other instructions to run this: apt-get update and I get this: Err:14 http://ppa.launchpad.net/ondrej/apache2/ubuntu cosmic/main amd64 Packages 404 Not Found Err:15 http://ppa.launchpad.net/ondrej/php/ubuntu cosmic/main amd64 Packages 404 Not Found and — I think because of that — I then get:

The repository 'http://ppa.launchpad.net/ondrej/apache2/ubuntu cosmic Release' does not have a Release file. 

By this stage, I’m still getting this on apt-get update:

Package 'php7.0-mysql' has no installation candidate. 

I start trying to add in php libraries, got Unicode issues, tried to get around that and. you get the idea. whack-a-mole. I gave up and looked to see if I could compile it and I found the answer I started with.

Читайте также:  Astra linux special edition mysql

You might be wondering why I wrote so much? So that anyone googling can find this solution (including me!).

Источник

Linux php pdo install

Check the system logs to confirm that there are no related errors. You can use ZoomAdmin to check the logs, manager servers, host multiple websites and apps on your servers and more. The apps run in docker containers, to learn more
see ZoomAdmin Features for list of features and demo videos. And you can start with the Free Plan.

Execute the commands above step by step. You can simply hit the copy button to copy the command and paste into the command line interface.
Note: -y flag means to assume yes and silently install, without asking you questions in most cases.

Package Description
Detailed Instructions:
Step 1
Step 2
Step 3

Check the system logs to confirm that there are no related errors. You can use ZoomAdmin to check the logs, manager servers, host multiple websites and apps on your servers and more. The apps run in docker containers, to learn more
see ZoomAdmin Features for list of features and demo videos. And you can start with the Free Plan.

We use cookies to provide better service. For more information please see our Privacy Policy.
By continuing to browse our website, you agree to our use of cookies.

Get connected with us on social networks!
ZoomAdmin

We provide cloud-based platform to easily manage and maintain your servers and apps, using intuitive web interface and modern technology.

Источник

Оцените статью
Adblock
detector