0

I've searched on thousand posts and still did not find a solution for my issue. Other posts there's no answer. Please do not mark as duplicate, because it isn't. In my case, the file exists on directory but is not recognized.

I am getting the error PHP Warning: PHP Startup: Unable to load dynamic library 'pdo_mysql.so' when I type the command:

php -v

I got this output:

PHP Warning:  PHP Startup: Unable to load dynamic library 'pdo_mysql.so' (tried: /usr/lib/php/20190902/pdo_mysql.so (/usr/lib/php/20190902/pdo_mysql.so: undefined symbol: mysqlnd_allocator), /usr/lib/php/20190902/pdo_mysql.so.so (/usr/lib/php/20190902/pdo_mysql.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
PHP 7.4.3 (cli) (built: Mar  2 2022 15:36:52) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.3, Copyright (c), by Zend Technologies

I have reinstalled php-mysql several times, tried to install the module pdo-mysql itself and nothing.

With the command php -m , i got all module (but missing pdo_mysql)

PHP Warning:  PHP Startup: Unable to load dynamic library 'pdo_mysql.so' (tried: /usr/lib/php/20190902/pdo_mysql.so (/usr/lib/php/20190902/pdo_mysql.so: undefined symbol: mysqlnd_allocator), /usr/lib/php/20190902/pdo_mysql.so.so (/usr/lib/php/20190902/pdo_mysql.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
[PHP Modules]
bz2
calendar
Core
ctype
curl
date
dom
exif
FFI
fileinfo
filter
ftp
gd
gettext
hash
iconv
imagick
json
libxml
mbstring
openssl
pcntl
pcre
PDO
Phar
posix
readline
Reflection
session
shmop
SimpleXML
sockets
sodium
SPL
ssh2
standard
sysvmsg
sysvsem
sysvshm
tokenizer
xml
xmlreader
xmlwriter
xsl
Zend OPcache
zip
zlib

[Zend Modules]
Zend OPcache

But the file itself exists on directory mentioned on the error:

/usr/lib/php/20190902  ls -la                                                                                                   ✔  4 ⚙  3444  19:35:10
total 9,9M
drwxr-xr-x 2 root root 4,0K Mar  5 18:46 .
drwxr-xr-x 4 root root 4,0K Mar  5 18:46 ..
-rw-r--r-- 1 root root  31K Mar  2 12:36 bz2.so
-rw-r--r-- 1 root root  43K Mar  2 12:36 calendar.so
-rw-r--r-- 1 root root  15K Mar  2 12:36 ctype.so
-rw-r--r-- 1 root root 103K Mar  2 12:36 curl.so
-rw-r--r-- 1 root root 167K Mar  2 12:36 dom.so
-rw-r--r-- 1 root root  91K Mar  2 12:36 exif.so
-rw-r--r-- 1 root root 159K Mar  2 12:36 ffi.so
-rw-r--r-- 1 root root 5,5M Mar  2 12:36 fileinfo.so
-rw-r--r-- 1 root root  67K Mar  2 12:36 ftp.so
-rw-r--r-- 1 root root 115K Mar  2 12:36 gd.so
-rw-r--r-- 1 root root  19K Mar  2 12:36 gettext.so
-rw-r--r-- 1 root root  51K Mar  2 12:36 iconv.so
-rw-r--r-- 1 root root 448K Mar  2  2020 imagick.so
-rw-r--r-- 1 root root  47K Mar  2 12:36 json.so
-rw-r--r-- 1 root root 1,1M Mar  2 12:36 mbstring.so
-rw-r--r-- 1 root root 143K Mar  2 12:36 mysqli.so
-rw-r--r-- 1 root root 254K Mar  2 12:36 mysqlnd.so
-rw-r--r-- 1 root root 543K Mar  2 12:36 opcache.so
-rw-r--r-- 1 root root  35K Mar  2 12:36 pdo_mysql.so
-rw-r--r-- 1 root root 111K Mar  2 12:36 pdo.so
-rw-r--r-- 1 root root 275K Mar  2 12:36 phar.so
-rw-r--r-- 1 root root  43K Mar  2 12:36 posix.so
-rw-r--r-- 1 root root  39K Mar  2 12:36 readline.so
-rw-r--r-- 1 root root  15K Mar  2 12:36 shmop.so
-rw-r--r-- 1 root root  55K Mar  2 12:36 simplexml.so
-rw-r--r-- 1 root root  99K Mar  2 12:36 sockets.so
-rw-r--r-- 1 root root  89K Feb 28  2020 ssh2.so
-rw-r--r-- 1 root root  23K Mar  2 12:36 sysvmsg.so
-rw-r--r-- 1 root root  15K Mar  2 12:36 sysvsem.so
-rw-r--r-- 1 root root  19K Mar  2 12:36 sysvshm.so
-rw-r--r-- 1 root root  27K Mar  2 12:36 tokenizer.so
-rw-r--r-- 1 root root  39K Mar  2 12:36 xmlreader.so
-rw-r--r-- 1 root root  55K Mar  2 12:36 xml.so
-rw-r--r-- 1 root root  51K Mar  2 12:36 xmlwriter.so
-rw-r--r-- 1 root root  35K Mar  2 12:36 xsl.so
-rw-r--r-- 1 root root  71K Mar  2 12:36 zip.so

I'm on a Linux Mint 20, latest version of php, mysql and apache. Does anybody know how to install pdo_mysql and get rid of this issue?

Kelson Batista
  • 406
  • 4
  • 25
  • I've seen this post, didn't help, also do not have the right answer. – Kelson Batista Mar 05 '22 at 22:12
  • 1
    Before you dismiss every other possible duplicate on this site, explain why they're not duplicates. If you don't, you'll get a lot of this. – Tangentially Perpendicular Mar 05 '22 at 22:13
  • 1
    You don't state what operating system you are using, but I guess from the `.so` extension that it's some version of Linux or UNIX or maybe MacOS? In most Linux distros I've used, the pdo_mysql extension is installed as a separate package and it's not installed by default. You have to search the package repo for the right package name, and install it. I can't be more specific unless you say what environment you are working in, and you show how you have tried to install it so far. – Bill Karwin Mar 05 '22 at 22:16
  • @TangentiallyPerpendicular the other post has no solution and nobody answered anymore. – Kelson Batista Mar 05 '22 at 22:21
  • @BillKarwin Sorry, I forgot to write, I'm using Linux Mint 20 with latest version of mysql, php and apache. I have tried to install it individually with the command apt-get install php-pdo-mysql but didn't work, it says php7.4-mysql is already the newest version (7.4.3-4ubuntu2.10). Do you have any other command to get it? – Kelson Batista Mar 05 '22 at 22:26
  • I can't use Mint because there's no Docker image for Mint on ARM64 yet. But I just build an Ubuntu container and I was able to `apt-get install php php-mysql` and I confirm with `php -m` that this installed mysqlnd and PDO and pdo_mysql. I followed instructions here: https://computingforgeeks.com/how-to-install-php-on-ubuntu/ – Bill Karwin Mar 05 '22 at 23:45
  • @BillKarwin I repeated the process here and the pdo_mysql still missing. That's weird. :/ – Kelson Batista Mar 05 '22 at 23:54

1 Answers1

0

For those with same issue, I just found a solution. When it's unable to load dynamically, in my case meant I probably had a broken php installation (e.g. corrupted file), so I had to reinstall it, but just installing it again the issue remained. In this case I had to completely remove the php files and then reinstall it again. Here are the steps I took:

  1. First uninstall only the php related files. The command below search and purge for those specific php files.

    sudo apt-get purge dpkg -l | grep php| awk '{print $2}' |tr "\n" " "

    If everything ok, jump to step 2. During this process, I found another error:

    sub-process /usr/bin/dpkg returned an error code (1)

    dpkg: error processing package phpmyadmin (--configure): installed phpmyadmin package post-installation script subprocess returned error exit status 127

    So I completely removed phpmyadmin files

    sudo apt-get purge phpmyadmin

    rm -r /var/lib/dpkg/info/phpmyadmin.*

    sudo apt-get clean
    && sudo apt-get update
    && sudo apt-get remove phpmyadmin
    && sudo apt-get purge phpmyadmin

After that I was able to completely remove php:

sudo apt-get purge dpkg -l | grep php| awk '{print $2}' |tr "\n" " "
  1. After that, reinstall php again, then all should be running smoothly (ref: https://www.digitalocean.com/community/tutorials/how-to-install-php-7-4-and-set-up-a-local-development-environment-on-ubuntu-20-04)

    sudo apt-get update

    sudo apt -y install software-properties-common

    sudo add-apt-repository ppa:ondrej/php

    sudo apt-get update

    sudo apt -y install php7.4

    php -v (check php working)

  2. And finally install phpMyAdmin again:

    sudo apt update

    sudo apt install phpmyadmin php-mbstring php-zip php-gd php-json php-curl

    sudo phpenmod mbstring

    sudo systemctl restart apache2

Kelson Batista
  • 406
  • 4
  • 25