5

Getting this warning on a custom-compiled version of PHP7, even when running php -v.

Tried all solutions posted. What could cause this?

PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/20151012/pdo_mysql.so' - /usr/lib/php/20151012/pdo_mysql.so: undefined symbol: mysqlnd_allocator in Unknown on line 0

There are similar questions to this, but they are not quite the same problem - they generally relate to a missing mcrypt library. I confirmed that mycrypt is in fact loaded, as well as pdo_mysql when printing out phpinfo().

Is there something wrong with the order? Also, this is for PHP 7, which I believe has different formats for ini files.


Edit: Following instructions here for recompile. Not too experienced in this: http://www.hashbangcode.com/blog/compiling-and-installing-php7-ubuntu

Also, removed MySQL completely with apt-get purge. No luck with anything.

halfer
  • 19,824
  • 17
  • 99
  • 186
KodiakSA
  • 193
  • 2
  • 3
  • 9
  • Did you recompile PHP? [This resource](https://dev.mysql.com/downloads/connector/php-mysqlnd/) indicates that the C-level library used to power the PHP MySQL library is a compile-time decision. So, it sounds like it has been wrongly compiled. – halfer Jun 27 '16 at 16:11
  • KodiakSA, when asking questions, please try to make amendments such that the question still makes sense to the brand new reader (this is good general advice rather than specifically just on this question). If the first thing people see is "this is not a dup" then that will only make sense to people who saw the first version. – halfer Jun 27 '16 at 16:31
  • I have tried to recompile, I'm on ubuntu.. I have also purged and reinstalled php and php_mysql. – KodiakSA Jun 27 '16 at 16:37
  • halfer. Will do with respect to dups etc.. new to this! Thanks – KodiakSA Jun 27 '16 at 16:38
  • OK. Would you edit in your compilation commands/flags etc? That stuff makes a great deal of difference. We'll try to get this question re-opened if you can do that. – halfer Jun 27 '16 at 16:40
  • You should not need to do anything with `apt-get` if you are doing a custom compilation - reset the binary target to something other than the default location of `php` and then just change your paths (console and web server) so the new version is used. – halfer Jun 27 '16 at 19:28
  • What version of Ubuntu are you using? Please edit it into your question (i.e. not in the comments please). – halfer Jun 27 '16 at 19:29
  • To debug this further, consider setting up a new Ubuntu virtual machine (e.g. using VirtualBox locally, or [a free one](http://c9.io/)) and seeing if a custom compilation works there. If it fails in a similar manner, edit your post with the **exact** list of commands you used (i.e. don't just offer an external link, put the actual commands in a code block in your post). Thanks! – halfer Jun 27 '16 at 19:31

3 Answers3

4

I found that I had

extension=pdo_mysql

uncommented in my php.ini file and this was causing the problem. Libraries are loaded by the files in the /etc/php/7.4/cli/conf.d/ file on my system and don't need to be loaded by uncommenting lines in the php.ini file.

Darrell Duane
  • 3,874
  • 1
  • 18
  • 9
2

(Posted on behalf of the OP).

Commands performed in order; I removed MySQL and PHP completely from system then:

sudo apt-get update
sudo apt-get install php7.0
sudo apt-get install php7.0-mysql

This seems to have fixed the error. Uuuugh.

halfer
  • 19,824
  • 17
  • 99
  • 186
1

Sometimes there is an issue with not loaded correctly extensions in the php.ini file. I had similar error and it start working only after I have added these extensions before pdo_mysql to the php.ini:

extension=mysqlnd    
extension=pdo
extension=pdo_mysql

And it finally worked!

However it shows warnings that mysqlnd, PDO and pdo_mysql was loaded before, it means that pdo_mysql already enabled and can be commented out at all. For further info please check PHP Warning: Module already loaded in Unknown on line 0

Sergey
  • 11
  • 3