Php not loading mysql

PHP not loading extensions

I have am running a local server with PHP 5.3.6, and Apache 2.2.19 running on Ubuntu 11.03. I build both Apache and PHP from source. PHP is working fine with Apache, however it seems to never load any extensions. I have uncommented the ones I want PHP to load, I have checked that PHP is reading the INI file, I have uncommented the extension_dir directive and made sure it was correct. The files mysqli.so and mysql.so seems to be missing, with a lot of other files too. This was my first time installing PHP from source. I am aware that PHP 5.3.6 does not bundle the MySQL client libraries. I also checked the PHP repository, and it is no longer maintained. I could use PDO, but I much prefer using the MySQL class. My question is: Where do I get these files from? I have checked the MySQL site, and it doesn’t really help me. PHP only seems to be loading the extensions that are already built into PHP.

2 Answers 2

MySQL extensions come in separate packages:

$ apt-cache search mysql |grep php 

This is what I have on debian (and it worked automatically after installing it via apt-get):

plaes@machine:~$ dpkg -L php5-mysql /. /etc /etc/php5 /etc/php5/conf.d /etc/php5/conf.d/pdo_mysql.ini /etc/php5/conf.d/mysqli.ini /etc/php5/conf.d/mysql.ini /usr /usr/share /usr/share/doc /usr/lib /usr/lib/php5 /usr/lib/php5/20090626 /usr/lib/php5/20090626/mysqli.so /usr/lib/php5/20090626/pdo_mysql.so /usr/lib/php5/20090626/mysql.so /usr/share/doc/php5-mysql 

Источник

Arch Linux

I have bitten the bullet and upgraded to the Apache 2.4 and PHP from testing and solved a 10 tons of post-upgrade config nightmares just to figure out that MariaDB will not work with those versions until recompiled against them. Can we please have MariaDB added to testing repo after it was compiled against the Apache and PHP from testing?

Last edited by AndrzejL (2014-03-02 22:53:23)

#2 2014-03-02 08:34:19

Re: [SOLVED] Php not loading mysql extensions [Merge php.ini.pacnew file].

How does MariaDB depend on Apache or even PHP? What problems did you have exactly?

#3 2014-03-02 08:44:58

Re: [SOLVED] Php not loading mysql extensions [Merge php.ini.pacnew file].

How does MariaDB depend on Apache or even PHP? What problems did you have exactly?

[01-Mar-2014 20:37:04 Europe/Dublin] PHP Fatal error: Class 'mysqli' not found in /var/www/html/images/include/dblayer/functions_mysqli.inc.php on line 61

Also WordPress and Coppermine are screaming about missing MySQL plugins.

Last edited by AndrzejL (2014-03-02 08:46:44)

#4 2014-03-02 08:56:39

Re: [SOLVED] Php not loading mysql extensions [Merge php.ini.pacnew file].

I don’t see how that is related to Apache though. Are the mosql-modules enabled in php.ini? How are you using PHP?

Читайте также:  Css columns with flexbox

#5 2014-03-02 09:12:27

Re: [SOLVED] Php not loading mysql extensions [Merge php.ini.pacnew file].

So after 10 tons of nightmares you didn’t enable the mysql.so and mysqli.so extensions in your php.ini?

#6 2014-03-02 14:29:31

Re: [SOLVED] Php not loading mysql extensions [Merge php.ini.pacnew file].

I don’t see how that is related to Apache though. Are the mosql-modules enabled in php.ini?

So after 10 tons of nightmares you didn’t enable the mysql.so and mysqli.so extensions in your php.ini?

I am not an idiot guys (well maybe I am but. ), I would not come here and complain about missing extensions for mysql if I didnt tripple checked they were enabled in php.ini.

[root@icsserver andrzejl]# cat /etc/php/php.ini | grep -v ';' | grep -i mysql | grep ext extension=mysqli.so extension=mysql.so extension=pdo_mysql.so [root@icsserver andrzejl]# 

FPM/FastCGI / proxying all the php requests,

PHP is working fine from what I can see.

Andrzej_L_Arch_Linux_Screenshot_177.jpg

«Your PHP installation appears to be missing the MySQL extension which is required by WordPress.»

Which I assumed meant that the mysqld (in this case MariaDB) should be recompiled against php to provide those extensions. Could be wrong. Wouldn’t be the first time.

Last edited by AndrzejL (2014-03-02 15:01:43)

#7 2014-03-02 14:43:50

Re: [SOLVED] Php not loading mysql extensions [Merge php.ini.pacnew file].

Well then it should just work. How would mariadb be ‘recompiled against apache and php’? The php-modules are supplied by the php package; not mariadb or apache. What is the output of

#8 2014-03-02 14:48:24

Re: [SOLVED] Php not loading mysql extensions [Merge php.ini.pacnew file].

Well then it should just work. How would mariadb be ‘recompiled against apache and php’? The php-modules are supplied by the php package; not mariadb or apache. What is the output of

My mistake I thought that mysql extensions were provided by. mysql. Doesn’t sound illogical if You really think about it .

Array ( [0] => Core [1] => date [2] => ereg [3] => libxml [4] => pcre [5] => zlib [6] => ctype [7] => dom [8] => fileinfo [9] => filter [10] => hash [11] => json [12] => mbstring [13] => SPL [14] => PDO [15] => Reflection [16] => session [17] => SimpleXML [18] => standard [19] => tokenizer [20] => xml [21] => xmlreader [22] => xmlwriter [23] => mysqlnd [24] => cgi-fcgi [25] => mhash ) 

Last edited by AndrzejL (2014-03-02 15:00:50)

#9 2014-03-02 17:38:15

Re: [SOLVED] Php not loading mysql extensions [Merge php.ini.pacnew file].

both mysql and mysqli are not in that array, that means the extensions are not loaded. You obviously restart fpm after changing the ini? Does php_ini_loaded_file() output /etc/php/php.ini? What does `php` say when you run it on the cli? Does it output any errors?

Читайте также:  Html css open close

#10 2014-03-02 18:24:24

Re: [SOLVED] Php not loading mysql extensions [Merge php.ini.pacnew file].

both mysql and mysqli are not in that array, that means the extensions are not loaded. You obviously restart fpm after changing the ini?

Does php_ini_loaded_file() output /etc/php/php.ini?

What does `php` say when you run it on the cli? Does it output any errors?

No. It just waits there until I ^c it. Does not gives prompt back until I do so.

#11 2014-03-02 22:48:43

Re: [SOLVED] Php not loading mysql extensions [Merge php.ini.pacnew file].

Ok its my fault completely. I have not noticed /etc/php/php.ini.pacnew and I have never merged them.

Turns out I am an idiot after all. After opening the documents side by side, eyeballing for differences and changing several options in the pacnew version I have copied its content and pasted it in the php.ini file and restarted the php-pfm.

Array ( [0] => Core [1] => date [2] => ereg [3] => libxml [4] => pcre [5] => zlib [6] => ctype [7] => dom [8] => fileinfo [9] => filter [10] => hash [11] => json [12] => mbstring [13] => SPL [14] => PDO [15] => Reflection [16] => session [17] => SimpleXML [18] => standard [19] => tokenizer [20] => xml [21] => xmlreader [22] => xmlwriter [23] => mysqlnd [24] => cgi-fcgi [25] => curl [26] => exif [27] => gd [28] => gettext [29] => mcrypt [30] => mysqli [31] => mysql [32] => openssl [33] => pdo_mysql [34] => mhash )

Appologies for a false alarm. I know I should always merge the pacnew files — it just slipped past me without me noticing it.

Last edited by AndrzejL (2014-03-02 22:56:38)

Источник

Arch Linux

I am trying to fix my php7 setup for some time now, without success. I now need some help because I just have no idea what to try next.

None of my php webapps do work. Any hints are welcome. I start with the error given by tt-rss:

Exception while creating PDO object:could not find driver

So I check if my php7 setup is configured correctly:

php7 -m |grep pdo pdo_mysql php7 -i |grep PDO PDO PDO support => enabled PDO drivers => mysql PDO Driver for MySQL => enabled cat /etc/httpd/conf/httpd.conf |grep -i php LoadModule php7_module modules/libphp7.so Include conf/extra/php7_module.conf

mnc5jUI.png

I created an info.php and there I can see that the PDO driver is not loaded:

I assume on a working setup, «mysql» would be listed in this category. But I don’t see why it shouldn’t be loaded.

I am happy to produce any logs you may need to help me. Thanks already for reading until here and best regards,

Last edited by Watnuss (2021-02-08 20:29:03)

#2 2021-02-08 13:11:50

Re: [SOLVED] PHP7 PDO mysql driver not loaded

*bump*
I am going to build a mirror setup of the system in question trying to figure out what is wrong, next. In the meantime, I would be immensely thankful for any input.

#3 2021-02-08 17:44:56

Re: [SOLVED] PHP7 PDO mysql driver not loaded

i just set up a test-vm with a basic apache-php7-mysql-installation and after configuring it there was nothing special about getting PDO to work…

Читайте также:  Display all records from Database

Could you share your complete phpinfo()-test-page as well as the output of

#4 2021-02-08 19:07:44

Re: [SOLVED] PHP7 PDO mysql driver not loaded

the phpinfo() output can be found at nopaste.ml (This site encodes the paste in the url. Pastebin was not working for me.)
And

grep pdo /etc/php7/php.ini ;extension=pdo_dblib extension=pdo_mysql ;extension=pdo_odbc ;extension=pdo_pgsql ;extension=pdo_sqlite ; http://php.net/pdo-odbc.connection-pooling ;pdo_odbc.connection_pooling=strict ;pdo_odbc.db2_instance_name pdo_mysql.default_socket=

Last edited by Watnuss (2021-02-08 19:09:06)

#5 2021-02-08 19:58:13

Re: [SOLVED] PHP7 PDO mysql driver not loaded

There is a non-standard loaded configuration file. =>

Loaded Configuration File: /etc/webapps/tt-rss/php.ini

I dont’t know why it is loaded, but my guess is, that you have to enable the pdo-extension in this file, because the standard file does not seem to be loaded.

#6 2021-02-08 20:28:37

Re: [SOLVED] PHP7 PDO mysql driver not loaded

Thanks for the pointer. This config is loaded for the tt-rss webapp I am running.

 cat /etc/httpd/conf/httpd.conf|grep tt-rss # tt-rss settings Include conf/extra/tt-rss.conf

And that config looks like:

cat /etc/httpd/conf/extra/tt-rss.conf SSLEngine on #SSLCipherSuite HIGH:MEDIUM:!aNULL:!MD5 SSLCipherSuite HIGH:!aNULL:!MD5 ServerName tt-rss.myserver.net ServerAdmin admin@myserver.net DocumentRoot /usr/share/webapps/tt-rss #SSLCertificateFile /etc/httpd/conf/server.crt SSLCertificateFile /etc/letsencrypt/live/myserver.net/fullchain.pem #SSLCertificateKeyFile /etc/httpd/conf/server.key SSLCertificateKeyFile /etc/letsencrypt/live/myserver.net/privkey.pem SSLCertificateChainFile /etc/letsencrypt/live/myserver.net/chain.pem Options FollowSymlinks Require all granted AllowOverride all #php_admin_value open_basedir none php_admin_value open_basedir "/var/lib/tt-rss:/usr/share/webapps/tt-rss:/etc/webapps/tt-rss:/srv/http" PHPINIDir /etc/webapps/tt-rss ErrorLog /var/log/httpd/tt-rss.info-error_log CustomLog /var/log/httpd/tt-rss.info-access_log common ServerName tt-rss.myserver.net ServerAdmin admin@myserver.net DocumentRoot /usr/share/webapps/tt-rss Redirect permanent tt-rss.myserver.net https://tt-rss.myserver.net/ 
 PHPINIDir /etc/webapps/tt-rss

I just deleted it. It was in my config commented out before.
I must have introduced this error from an old config while merging configs between updated-to php8 and then newly installed php7 compatibility packages. Thank you very very much hoerbert. I was looking through logs for ages and tried a lot of different configs (already thought I totally messed up my setup, and I kind of did, just not totally)

You made my day. Thanks!

Источник

Почему php не может подключиться к БД?

FanatPHP

ЗЫ. На боевом сервере ошибки на экран выводить конечно не стоит, а их надо писать в лог (собственно, именно поэтому все эти die — это ужас). И на боевом сервере display_errors надо отключать, а log_errors наоборот — подключать.
Если совсем не можешь найти, где у сервера висит лог ошибок, можешь задать свой собственный, с помощью функции ini_set(‘error_log’,’/путь/к/файлу’); . Но только размещать его надо разумеется в папке недоступной пользователям сайта

Если же говорить о конкретно этой проблеме, то это очень забавная ошибка, в которой смешалась куча старого карго культ кода, который и сам по себе использовать не стоит, и вдобавок он здесь написан неправильно.

Если разобраться, то код or die(«Ошибка1 » . mysqli_error($link)); очень смешной (это не к тебе претензия, никто не ожидает от тебя понимания таких тонкостей, которые не то что новички, а половина здешних «кураторов» не понимают).
Что тут происходит?
слово or die (которое на самом деле вообще нельзя никогда писать) пишут тогда, когда ожидают что в переменной $link будет значение false. Но если в $link будет false, то тогда её бессмысленно подставлять в mysqli_error. Именно поэтому для получения ошибки соединения в мускули есть отдельная специальная функция.

Но как я говорил выше, применять её не следует, как и or die.

Источник

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